File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed 
rust-runtime/aws-smithy-http-server/examples/pokemon-service/src Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -226,8 +226,8 @@ pub async fn capture_pokemon(
226226                    Some ( event)  => { 
227227                        let  capturing_event = event. as_event( ) ; 
228228                        if  let  Ok ( attempt)  = capturing_event { 
229-                             let  payload = attempt. payload. clone( ) . unwrap_or ( CapturingPayload :: builder( ) . build( ) ) ; 
230-                             let  pokeball = payload. pokeball. as_ref ( ) . map ( |ball| ball . as_str ( ) ) . unwrap_or( "" ) ; 
229+                             let  payload = attempt. payload. clone( ) . unwrap_or_else ( ||  CapturingPayload :: builder( ) . build( ) ) ; 
230+                             let  pokeball = payload. pokeball. as_deref ( ) . unwrap_or( "" ) ; 
231231                            if  ! matches!( pokeball,  "Master Ball"  | "Great Ball"  | "Fast Ball" )  { 
232232                                yield Err ( 
233233                                    crate :: error:: CapturePokemonEventsError :: InvalidPokeballError ( 
@@ -250,8 +250,7 @@ pub async fn capture_pokemon(
250250                                    let  shiny = rand:: thread_rng( ) . gen_range( 0 ..4096 )  == 0 ; 
251251                                    let  pokemon = payload
252252                                        . name
253-                                         . as_ref( ) 
254-                                         . map( |name| name. as_str( ) ) 
253+                                         . as_deref( ) 
255254                                        . unwrap_or( "" ) 
256255                                        . to_string( ) ; 
257256                                    let  pokedex:  Vec <u8 > = ( 0 ..255 ) . collect( ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments