Skip to content

Commit a9f371f

Browse files
committed
Clean up tokio-postgres example a bit
1 parent dc9d07e commit a9f371f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tokio-postgres/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! # Example
44
//!
55
//! ```no_run
6-
//! use futures::FutureExt;
76
//! use tokio_postgres::{NoTls, Error, Row};
87
//!
98
//! # #[cfg(not(feature = "runtime"))] fn main() {}
@@ -16,18 +15,17 @@
1615
//!
1716
//! // The connection object performs the actual communication with the database,
1817
//! // so spawn it off to run on its own.
19-
//! let connection = connection.map(|r| {
20-
//! if let Err(e) = r {
18+
//! tokio::spawn(async move {
19+
//! if let Err(e) = connection.await {
2120
//! eprintln!("connection error: {}", e);
2221
//! }
2322
//! });
24-
//! tokio::spawn(connection);
2523
//!
2624
//! // Now we can prepare a simple statement that just returns its parameter.
2725
//! let stmt = client.prepare("SELECT $1::TEXT").await?;
2826
//!
29-
//! // And then execute it, returning a Stream of Rows which we collect into a Vec.
30-
//! let rows: Vec<Row> = client
27+
//! // And then execute it, returning a list of the resulting rows.
28+
//! let rows = client
3129
//! .query(&stmt, &[&"hello world"])
3230
//! .await?;
3331
//!

0 commit comments

Comments
 (0)