From 112ed5dcd6a4bb1e843eec8cbc2c076bb4058eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Tue, 27 Aug 2024 16:21:08 +0200 Subject: [PATCH] docs: use query_iter for SELECT in quickstart example We shouldn't encourage users to perform unpaged SELECTs. Normally, SELECTs should be paged, therefore the quickstart example is modified to use query_iter instead of query_unpaged. --- docs/source/quickstart/example.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/source/quickstart/example.md b/docs/source/quickstart/example.md index fde78fd474..f01a761c4c 100644 --- a/docs/source/quickstart/example.md +++ b/docs/source/quickstart/example.md @@ -5,7 +5,9 @@ Here is a small example: ```rust # extern crate scylla; # extern crate tokio; -use scylla::{IntoTypedRows, Session, SessionBuilder}; +# extern crate futures; +use futures::TryStreamExt; +use scylla::{Session, SessionBuilder}; use std::error::Error; #[tokio::main] @@ -43,9 +45,10 @@ async fn main() -> Result<(), Box> { .await?; // Query rows from the table and print them - let result = session.query_unpaged("SELECT a FROM ks.extab", &[]).await?; - let mut iter = result.rows_typed::<(i32,)>()?; - while let Some(read_row) = iter.next().transpose()? { + let mut iter = session.query_iter("SELECT a FROM ks.extab", &[]) + .await? + .into_typed::<(i32,)>(); + while let Some(read_row) = iter.try_next().await? { println!("Read a value from row: {}", read_row.0); }