From 5975fa95e8c0a755ca0809cbba435814d79b6623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Tue, 27 Aug 2024 15:56:19 +0200 Subject: [PATCH] docs: use query_iter in SELECT example in README We shouldn't encourage users to perform unpaged SELECTs. Normally, SELECTs should be paged, therefore the example in README is modified to use query_iter instead of query_unpaged. --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e215a80319..35ed844776 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,15 @@ The [documentation book](https://rust-driver.docs.scylladb.com/stable/index.html ## Examples ```rust +use futures::TryStreamExt; + let uri = "127.0.0.1:9042"; let session: Session = SessionBuilder::new().known_node(uri).build().await?; -let result = session.query_unpaged("SELECT a, b, c FROM ks.t", &[]).await?; -let mut iter = result.rows_typed::<(i32, i32, String)>()?; -while let Some((a, b, c)) = iter.next().transpose()? { +let raw_iter = session.query_iter("SELECT a, b, c FROM ks.t", &[]).await?; +let mut iter = raw_iter.into_typed::<(i32, i32, String)>(); +while let Some((a, b, c)) = iter.try_next().await? { println!("a, b, c: {}, {}, {}", a, b, c); } ```