Skip to content

Commit 57af12d

Browse files
committed
Remove lifetime from Rows
1 parent d0a5241 commit 57af12d

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

postgres/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ impl Connection {
11561156
/// println!("foo: {}", foo);
11571157
/// }
11581158
/// ```
1159-
pub fn query(&self, query: &str, params: &[&ToSql]) -> Result<Rows<'static>> {
1159+
pub fn query(&self, query: &str, params: &[&ToSql]) -> Result<Rows> {
11601160
let (param_types, columns) = self.0.borrow_mut().raw_prepare("", query)?;
11611161
let info = Arc::new(StatementInfo {
11621162
name: String::new(),
@@ -1376,7 +1376,7 @@ pub trait GenericConnection {
13761376
fn execute(&self, query: &str, params: &[&ToSql]) -> Result<u64>;
13771377

13781378
/// Like `Connection::query`.
1379-
fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows<'static>>;
1379+
fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows>;
13801380

13811381
/// Like `Connection::prepare`.
13821382
fn prepare<'a>(&'a self, query: &str) -> Result<Statement<'a>>;
@@ -1399,7 +1399,7 @@ impl GenericConnection for Connection {
13991399
self.execute(query, params)
14001400
}
14011401

1402-
fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows<'static>> {
1402+
fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows> {
14031403
self.query(query, params)
14041404
}
14051405

@@ -1429,7 +1429,7 @@ impl<'a> GenericConnection for Transaction<'a> {
14291429
self.execute(query, params)
14301430
}
14311431

1432-
fn query<'b>(&'b self, query: &str, params: &[&ToSql]) -> Result<Rows<'static>> {
1432+
fn query<'b>(&'b self, query: &str, params: &[&ToSql]) -> Result<Rows> {
14331433
self.query(query, params)
14341434
}
14351435

postgres/src/rows.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use std::io;
1010
use std::ops::Deref;
1111
use std::slice;
1212
use std::sync::Arc;
13-
use std::marker::PhantomData;
1413

1514
use {Result, StatementInfo};
1615
use transaction::Transaction;
@@ -35,14 +34,12 @@ impl<'a, T> Deref for MaybeOwned<'a, T> {
3534
}
3635

3736
/// The resulting rows of a query.
38-
// FIXME remove lifetime
39-
pub struct Rows<'compat> {
37+
pub struct Rows {
4038
stmt_info: Arc<StatementInfo>,
4139
data: Vec<RowData>,
42-
_marker: PhantomData<&'compat u8>,
4340
}
4441

45-
impl<'a> fmt::Debug for Rows<'a> {
42+
impl fmt::Debug for Rows {
4643
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
4744
fmt.debug_struct("Rows")
4845
.field("columns", &self.columns())
@@ -51,17 +48,14 @@ impl<'a> fmt::Debug for Rows<'a> {
5148
}
5249
}
5350

54-
impl Rows<'static> {
55-
pub(crate) fn new(stmt: &Statement, data: Vec<RowData>) -> Rows<'static> {
51+
impl Rows {
52+
pub(crate) fn new(stmt: &Statement, data: Vec<RowData>) -> Rows {
5653
Rows {
5754
stmt_info: stmt.info().clone(),
5855
data: data,
59-
_marker: PhantomData,
6056
}
6157
}
62-
}
6358

64-
impl<'rows> Rows<'rows> {
6559
/// Returns a slice describing the columns of the `Rows`.
6660
pub fn columns(&self) -> &[Column] {
6761
&self.stmt_info.columns[..]
@@ -98,7 +92,7 @@ impl<'rows> Rows<'rows> {
9892
}
9993
}
10094

101-
impl<'a> IntoIterator for &'a Rows<'a> {
95+
impl<'a> IntoIterator for &'a Rows {
10296
type Item = Row<'a>;
10397
type IntoIter = Iter<'a>;
10498

postgres/src/stmt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'conn> Statement<'conn> {
5858
self.conn
5959
}
6060

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

postgres/src/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl<'conn> Transaction<'conn> {
222222
}
223223

224224
/// Like `Connection::query`.
225-
pub fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows<'static>> {
225+
pub fn query<'a>(&'a self, query: &str, params: &[&ToSql]) -> Result<Rows> {
226226
self.conn.query(query, params)
227227
}
228228

0 commit comments

Comments
 (0)