From ec1a5515ad027aa9b04d6927a98c4757ac845881 Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Tue, 21 Feb 2023 14:44:15 -0600 Subject: [PATCH] Address clippy warnings in pokemon-service (#2399) Co-authored-by: Yuki Saito --- .../examples/pokemon-service/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rust-runtime/aws-smithy-http-server/examples/pokemon-service/src/lib.rs b/rust-runtime/aws-smithy-http-server/examples/pokemon-service/src/lib.rs index 0beb61b110..f04050b72f 100644 --- a/rust-runtime/aws-smithy-http-server/examples/pokemon-service/src/lib.rs +++ b/rust-runtime/aws-smithy-http-server/examples/pokemon-service/src/lib.rs @@ -226,8 +226,8 @@ pub async fn capture_pokemon( Some(event) => { let capturing_event = event.as_event(); if let Ok(attempt) = capturing_event { - let payload = attempt.payload.clone().unwrap_or(CapturingPayload::builder().build()); - let pokeball = payload.pokeball.as_ref().map(|ball| ball.as_str()).unwrap_or(""); + let payload = attempt.payload.clone().unwrap_or_else(|| CapturingPayload::builder().build()); + let pokeball = payload.pokeball.as_deref().unwrap_or(""); if ! matches!(pokeball, "Master Ball" | "Great Ball" | "Fast Ball") { yield Err( crate::error::CapturePokemonEventsError::InvalidPokeballError( @@ -250,8 +250,7 @@ pub async fn capture_pokemon( let shiny = rand::thread_rng().gen_range(0..4096) == 0; let pokemon = payload .name - .as_ref() - .map(|name| name.as_str()) + .as_deref() .unwrap_or("") .to_string(); let pokedex: Vec = (0..255).collect();