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 4
4
#[ rustfmt:: skip]
5
5
#[ allow( unused_variables, unused_assignments) ]
6
6
fn 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.
8
10
if my_option. is_none ( ) {
9
- println ! ( "{:? }" , my_option. unwrap( ) ) ;
11
+ println ! ( "{}" , my_option. unwrap( ) ) ;
10
12
}
11
13
12
14
let my_arr = & [
Original file line number Diff line number Diff line change @@ -3,11 +3,11 @@ use std::mem;
3
3
#[ rustfmt:: skip]
4
4
#[ allow( unused_variables, unused_assignments) ]
5
5
fn main ( ) {
6
- let my_option: Option < ( ) > = None ;
6
+ let my_option: Option < & str > = None ;
7
7
// `unwrap` of an `Option` after checking if it is `None` will panic.
8
8
// Use `if-let` instead.
9
9
if let Some ( value) = my_option {
10
- println ! ( "{value:? }" ) ;
10
+ println ! ( "{value}" ) ;
11
11
}
12
12
13
13
// A comma was missing.
You can’t perform that action at this time.
0 commit comments