diff --git a/rust_dev_preview/examples/globalaccelerator/src/bin/globalaccelerator-helloworld.rs b/rust_dev_preview/examples/globalaccelerator/src/bin/globalaccelerator-helloworld.rs index d8ceded526f..d108e66fd7a 100644 --- a/rust_dev_preview/examples/globalaccelerator/src/bin/globalaccelerator-helloworld.rs +++ b/rust_dev_preview/examples/globalaccelerator/src/bin/globalaccelerator-helloworld.rs @@ -21,17 +21,21 @@ struct Opt { async fn show_accelerators(client: &Client) -> Result<(), Error> { println!("Welcome to the AWS Rust SDK Global Accelerator example!"); println!(); - let mut paginator = client.list_accelerators().into_paginator().send(); + let accelerators = client + .list_accelerators() + .into_paginator() + .items() + .send() + .try_collect() + .await?; - while let Some(page) = paginator.try_next().await? { - for accelerator in page.accelerators().iter() { - let accelerator_arn = accelerator.name().unwrap_or_default(); - let accelerator_name = accelerator.accelerator_arn().unwrap_or_default(); + for accelerator in accelerators { + let accelerator_arn = accelerator.name().unwrap_or_default(); + let accelerator_name = accelerator.accelerator_arn().unwrap_or_default(); - println!("Accelerator Name : {}", accelerator_name); - println!("Accelerator ARN : {}", accelerator_arn); - println!(); - } + println!("Accelerator Name : {}", accelerator_name); + println!("Accelerator ARN : {}", accelerator_arn); + println!(); } Ok(()) diff --git a/rust_dev_preview/examples/iam/src/iam-service-lib.rs b/rust_dev_preview/examples/iam/src/iam-service-lib.rs index 4f6b71a25c3..5fb5c70be3a 100644 --- a/rust_dev_preview/examples/iam/src/iam-service-lib.rs +++ b/rust_dev_preview/examples/iam/src/iam-service-lib.rs @@ -371,33 +371,28 @@ pub async fn list_policies( client: iamClient, path_prefix: String, ) -> Result, SdkError> { - let mut list_policies = client + let list_policies = client .list_policies() .path_prefix(path_prefix) .scope(PolicyScopeType::Local) .into_paginator() - .send(); - - let mut v = Vec::new(); - - while let Some(list_policies_output) = list_policies.next().await { - match list_policies_output { - Ok(list_policies) => { - for policy in list_policies.policies() { - let policy_name = policy - .policy_name() - .unwrap_or("Missing policy name.") - .to_string(); - println!("{}", policy_name); - v.push(policy_name); - } - } - - Err(err) => return Err(err), - } - } + .items() + .send() + .try_collect() + .await?; - Ok(v) + let policy_names = list_policies + .into_iter() + .map(|p| { + let name = p + .policy_name + .unwrap_or_else(|| "Missing Policy Name".to_string()); + println!("{}", name); + name + }) + .collect(); + + Ok(policy_names) } // snippet-end:[rust.example_code.iam.hello_lib] // snippet-end:[rust.example_code.iam.service.list_policies]