Remove lifetime from Rows

This commit is contained in:
Steven Fackler 2017-07-09 16:05:12 -07:00
parent d0a5241931
commit 57af12d094
4 changed files with 12 additions and 18 deletions

View File

@ -1156,7 +1156,7 @@ impl Connection {
/// println!("foo: {}", foo);
/// }
/// ```
pub fn query(&self, query: &str, params: &[&ToSql]) -> Result<Rows<'static>> {
pub fn query(&self, query: &str, params: &[&ToSql]) -> Result<Rows> {
let (param_types, columns) = self.0.borrow_mut().raw_prepare("", query)?;
let info = Arc::new(StatementInfo {
name: String::new(),
@ -1376,7 +1376,7 @@ pub trait GenericConnection {
fn execute(&self, query: &str, params: &[&ToSql]) -> Result<u64>;
/// Like `Connection::query`.
fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows<'static>>;
fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows>;
/// Like `Connection::prepare`.
fn prepare<'a>(&'a self, query: &str) -> Result<Statement<'a>>;
@ -1399,7 +1399,7 @@ impl GenericConnection for Connection {
self.execute(query, params)
}
fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows<'static>> {
fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows> {
self.query(query, params)
}
@ -1429,7 +1429,7 @@ impl<'a> GenericConnection for Transaction<'a> {
self.execute(query, params)
}
fn query<'b>(&'b self, query: &str, params: &[&ToSql]) -> Result<Rows<'static>> {
fn query<'b>(&'b self, query: &str, params: &[&ToSql]) -> Result<Rows> {
self.query(query, params)
}

View File

@ -10,7 +10,6 @@ use std::io;
use std::ops::Deref;
use std::slice;
use std::sync::Arc;
use std::marker::PhantomData;
use {Result, StatementInfo};
use transaction::Transaction;
@ -35,14 +34,12 @@ impl<'a, T> Deref for MaybeOwned<'a, T> {
}
/// The resulting rows of a query.
// FIXME remove lifetime
pub struct Rows<'compat> {
pub struct Rows {
stmt_info: Arc<StatementInfo>,
data: Vec<RowData>,
_marker: PhantomData<&'compat u8>,
}
impl<'a> fmt::Debug for Rows<'a> {
impl fmt::Debug for Rows {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("Rows")
.field("columns", &self.columns())
@ -51,17 +48,14 @@ impl<'a> fmt::Debug for Rows<'a> {
}
}
impl Rows<'static> {
pub(crate) fn new(stmt: &Statement, data: Vec<RowData>) -> Rows<'static> {
impl Rows {
pub(crate) fn new(stmt: &Statement, data: Vec<RowData>) -> Rows {
Rows {
stmt_info: stmt.info().clone(),
data: data,
_marker: PhantomData,
}
}
}
impl<'rows> Rows<'rows> {
/// Returns a slice describing the columns of the `Rows`.
pub fn columns(&self) -> &[Column] {
&self.stmt_info.columns[..]
@ -98,7 +92,7 @@ impl<'rows> Rows<'rows> {
}
}
impl<'a> IntoIterator for &'a Rows<'a> {
impl<'a> IntoIterator for &'a Rows {
type Item = Row<'a>;
type IntoIter = Iter<'a>;

View File

@ -58,7 +58,7 @@ impl<'conn> Statement<'conn> {
self.conn
}
pub(crate) fn into_query(self, params: &[&ToSql]) -> Result<Rows<'static>> {
pub(crate) fn into_query(self, params: &[&ToSql]) -> Result<Rows> {
check_desync!(self.conn);
let mut rows = vec![];
self.inner_query("", 0, params, |row| rows.push(row))?;
@ -210,7 +210,7 @@ impl<'conn> Statement<'conn> {
/// println!("foo: {}", foo);
/// }
/// ```
pub fn query(&self, params: &[&ToSql]) -> Result<Rows<'static>> {
pub fn query(&self, params: &[&ToSql]) -> Result<Rows> {
check_desync!(self.conn);
let mut rows = vec![];
self.inner_query("", 0, params, |row| rows.push(row))?;

View File

@ -222,7 +222,7 @@ impl<'conn> Transaction<'conn> {
}
/// Like `Connection::query`.
pub fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows<'static>> {
pub fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows> {
self.conn.query(query, params)
}