@@ -360,26 +360,24 @@ fn exit_status(page: Roff, exit_statuses: &[ExitStatus]) -> Roff {
360
360
if exit_statuses. is_empty ( ) {
361
361
return page;
362
362
}
363
- let arr = if exit_statuses
364
- . iter ( )
365
- . any ( |status| status. use_default_instead )
366
- {
363
+ let should_use_default = exit_statuses. iter ( ) . any ( |s| s. use_default_instead ) ;
364
+ let arr = if should_use_default {
367
365
vec ! [
368
366
list( & [ bold( "0" ) ] , & [ "Successful program execution.\n \n " ] ) ,
369
367
list( & [ bold( "1" ) ] , & [ "Unsuccessful program execution.\n \n " ] ) ,
370
368
list( & [ bold( "101" ) ] , & [ "The program panicked." ] ) ,
371
369
]
372
370
} else {
373
- let mut arr = vec ! [ ] ;
374
- for exit_status in exit_statuses {
375
- let exit_code =
376
- format ! ( "{}" , exit_status . code. expect ( "initialized with value" ) ) ;
377
- let mut exit_description =
378
- String :: from ( exit_status . description . unwrap_or ( "" ) ) ;
379
- exit_description . push_str ( "\n \n " ) ;
380
- arr . push ( list ( & [ bold ( & exit_code ) ] , & [ exit_description ] ) ) ;
381
- }
382
- arr
371
+ exit_statuses
372
+ . into_iter ( )
373
+ . map ( |status| {
374
+ let code =
375
+ format ! ( "{}" , status . code . expect ( "initialized with a value" ) ) ;
376
+ let mut description = String :: from ( status . description . unwrap_or ( "" ) ) ;
377
+ description . push_str ( "\n \n " ) ;
378
+ list ( & [ bold ( & code ) ] , & [ description ] )
379
+ } )
380
+ . collect ( )
383
381
} ;
384
382
page. section ( "EXIT STATUS" , & arr)
385
383
}
0 commit comments