File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 44#[ rustfmt:: skip]
55#[ allow( unused_variables, unused_assignments) ]
66fn main ( ) {
7- let my_option: Option < ( ) > = None ;
7+ let my_option: Option < & str > = None ;
8+ // Assume that you don't know the value of `my_option`.
9+ // In the case of `Some`, we want to print its value.
810 if my_option. is_none ( ) {
9- println ! ( "{:? }" , my_option. unwrap( ) ) ;
11+ println ! ( "{}" , my_option. unwrap( ) ) ;
1012 }
1113
1214 let my_arr = & [
Original file line number Diff line number Diff line change @@ -3,11 +3,11 @@ use std::mem;
33#[ rustfmt:: skip]
44#[ allow( unused_variables, unused_assignments) ]
55fn main ( ) {
6- let my_option: Option < ( ) > = None ;
6+ let my_option: Option < & str > = None ;
77 // `unwrap` of an `Option` after checking if it is `None` will panic.
88 // Use `if-let` instead.
99 if let Some ( value) = my_option {
10- println ! ( "{value:? }" ) ;
10+ println ! ( "{value}" ) ;
1111 }
1212
1313 // A comma was missing.
You can’t perform that action at this time.
0 commit comments