diff --git a/examples/value_list.rs b/examples/value_list.rs index 54a0b0bed3..81568baeef 100644 --- a/examples/value_list.rs +++ b/examples/value_list.rs @@ -1,23 +1,23 @@ +use anyhow::Result; use scylla::{Session, SessionBuilder}; use std::env; #[tokio::main] -async fn main() { +async fn main() -> Result<()> { let uri = env::var("SCYLLA_URI").unwrap_or_else(|_| "127.0.0.1:9042".to_string()); println!("Connecting to {} ...", uri); - let session: Session = SessionBuilder::new().known_node(uri).build().await.unwrap(); + let session: Session = SessionBuilder::new().known_node(uri).build().await?; - session.query_unpaged("CREATE KEYSPACE IF NOT EXISTS examples_ks WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}", &[]).await.unwrap(); + session.query_unpaged("CREATE KEYSPACE IF NOT EXISTS examples_ks WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}", &[]).await?; session .query_unpaged( "CREATE TABLE IF NOT EXISTS examples_ks.my_type (k int, my text, primary key (k))", &[], ) - .await - .unwrap(); + .await?; #[derive(scylla::SerializeRow)] struct MyType<'a> { @@ -35,8 +35,7 @@ async fn main() { "INSERT INTO examples_ks.my_type (k, my) VALUES (?, ?)", to_insert, ) - .await - .unwrap(); + .await?; // You can also use type generics: #[derive(scylla::SerializeRow)] @@ -55,13 +54,13 @@ async fn main() { "INSERT INTO examples_ks.my_type (k, my) VALUES (?, ?)", to_insert_2, ) - .await - .unwrap(); + .await?; let q = session .query_unpaged("SELECT * FROM examples_ks.my_type", &[]) - .await - .unwrap(); + .await?; println!("Q: {:?}", q.rows); + + Ok(()) }