diff --git a/README.md b/README.md index 891a768f..2f437435 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ fn main() { &[&me.name, &me.data]).unwrap(); let stmt = conn.prepare("SELECT id, name, data FROM person").unwrap(); - for row in stmt.query(&[]).unwrap() { + for row in &stmt.query(&[]).unwrap() { let person = Person { id: row.get(0), name: row.get(1), diff --git a/src/lib.rs b/src/lib.rs index 6205b999..9fac74c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,7 @@ //! &[&me.name, &me.data]).unwrap(); //! //! let stmt = conn.prepare("SELECT id, name, data FROM person").unwrap(); -//! for row in stmt.query(&[]).unwrap() { +//! for row in &stmt.query(&[]).unwrap() { //! let person = Person { //! id: row.get(0), //! name: row.get(1), @@ -986,7 +986,7 @@ impl Connection { /// # let x = 10i32; /// # let conn = Connection::connect("", &SslMode::None).unwrap(); /// let stmt = conn.prepare("SELECT foo FROM bar WHERE baz = $1").unwrap(); - /// for row in stmt.query(&[&x]).unwrap() { + /// for row in &stmt.query(&[&x]).unwrap() { /// let foo: String = row.get(0); /// println!("foo: {}", foo); /// } @@ -1009,7 +1009,7 @@ impl Connection { /// # let x = 10i32; /// # let conn = Connection::connect("", &SslMode::None).unwrap(); /// let stmt = conn.prepare_cached("SELECT foo FROM bar WHERE baz = $1").unwrap(); - /// for row in stmt.query(&[&x]).unwrap() { + /// for row in &stmt.query(&[&x]).unwrap() { /// let foo: String = row.get(0); /// println!("foo: {}", foo); /// } diff --git a/src/rows.rs b/src/rows.rs index acd7711a..ba033020 100644 --- a/src/rows.rs +++ b/src/rows.rs @@ -5,7 +5,6 @@ use std::fmt; use std::collections::VecDeque; use std::borrow::Cow; use std::slice; -use std::vec; use {Result, Transaction, read_rows, DbErrorNew, SessionInfoNew, RowsNew, LazyRowsNew, StatementInternals}; @@ -79,18 +78,6 @@ impl<'a> IntoIterator for &'a Rows<'a> { } } -impl<'stmt> IntoIterator for Rows<'stmt> { - type Item = Row<'stmt>; - type IntoIter = IntoIter<'stmt>; - - fn into_iter(self) -> IntoIter<'stmt> { - IntoIter { - stmt: self.stmt, - iter: self.data.into_iter(), - } - } -} - /// An iterator over `Row`s. pub struct Iter<'a> { stmt: &'a Statement<'a>, @@ -127,42 +114,6 @@ impl<'a> DoubleEndedIterator for Iter<'a> { impl<'a> ExactSizeIterator for Iter<'a> {} -/// An owning iterator over `Row`s. -pub struct IntoIter<'stmt> { - stmt: &'stmt Statement<'stmt>, - iter: vec::IntoIter>>>, -} - -impl<'stmt> Iterator for IntoIter<'stmt> { - type Item = Row<'stmt>; - - fn next(&mut self) -> Option> { - self.iter.next().map(|row| { - Row { - stmt: self.stmt, - data: Cow::Owned(row), - } - }) - } - - fn size_hint(&self) -> (usize, Option) { - self.iter.size_hint() - } -} - -impl<'stmt> DoubleEndedIterator for IntoIter<'stmt> { - fn next_back(&mut self) -> Option> { - self.iter.next_back().map(|row| { - Row { - stmt: self.stmt, - data: Cow::Owned(row), - } - }) - } -} - -impl<'stmt> ExactSizeIterator for IntoIter<'stmt> {} - /// A single result row of a query. pub struct Row<'a> { stmt: &'a Statement<'a>, @@ -226,7 +177,7 @@ impl<'a> Row<'a> { /// # use postgres::{Connection, SslMode}; /// # let conn = Connection::connect("", &SslMode::None).unwrap(); /// let stmt = conn.prepare("SELECT foo, bar from BAZ").unwrap(); - /// for row in stmt.query(&[]).unwrap() { + /// for row in &stmt.query(&[]).unwrap() { /// let foo: i32 = row.get(0); /// let bar: String = row.get("bar"); /// println!("{}: {}", foo, bar); diff --git a/src/stmt.rs b/src/stmt.rs index 5d5909b2..dab4bb3e 100644 --- a/src/stmt.rs +++ b/src/stmt.rs @@ -229,7 +229,7 @@ impl<'conn> Statement<'conn> { /// # let conn = Connection::connect("", &SslMode::None).unwrap(); /// let stmt = conn.prepare("SELECT foo FROM bar WHERE baz = $1").unwrap(); /// # let baz = true; - /// for row in stmt.query(&[&baz]).unwrap() { + /// for row in &stmt.query(&[&baz]).unwrap() { /// let foo: i32 = row.get("foo"); /// println!("foo: {}", foo); /// } diff --git a/tests/test.rs b/tests/test.rs index d90bba7d..f41eaa9c 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -995,7 +995,7 @@ fn test_type_names() { AND n.nspname = 'pg_catalog' AND t.oid < 10000 AND t.typtype != 'c'").unwrap(); - for row in stmt.query(&[]).unwrap() { + for row in &stmt.query(&[]).unwrap() { let id: Oid = row.get(0); let name: String = row.get(1); assert_eq!(Type::from_oid(id).unwrap().name(), name);