Skip to content

Commit 89d39cc

Browse files
committed
Add an example to lazy_query
1 parent 36c5903 commit 89d39cc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

postgres/src/stmt.rs

+23
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,29 @@ impl<'conn> Statement<'conn> {
237237
/// `Connection` as this `Statement`, if the `Transaction` is not
238238
/// active, or if the number of parameters provided does not match the
239239
/// number of parameters expected.
240+
///
241+
/// # Examples
242+
///
243+
/// ```no_run
244+
/// extern crate fallible_iterator;
245+
/// extern crate postgres;
246+
///
247+
/// use fallible_iterator::FallibleIterator;
248+
/// # use postgres::{Connection, TlsMode};
249+
///
250+
/// # fn main() {
251+
/// # let conn = Connection::connect("", TlsMode::None).unwrap();
252+
/// let stmt = conn.prepare("SELECT foo FROM bar WHERE baz = $1").unwrap();
253+
/// let trans = conn.transaction().unwrap();
254+
/// # let baz = true;
255+
/// let mut rows = stmt.lazy_query(&trans, &[&baz], 100).unwrap();
256+
///
257+
/// while let Some(row) = rows.next().unwrap() {
258+
/// let foo: i32 = row.get("foo");
259+
/// println!("foo: {}", foo);
260+
/// }
261+
/// # }
262+
/// ```
240263
pub fn lazy_query<'trans, 'stmt>(
241264
&'stmt self,
242265
trans: &'trans Transaction,

0 commit comments

Comments
 (0)