File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,10 @@ fn or_fun_call() {
64
64
65
65
let stringy = Some ( String :: from ( "" ) ) ;
66
66
let _ = stringy. unwrap_or ( "" . to_owned ( ) ) ;
67
+
68
+ let opt = Some ( 1 ) ;
69
+ let hello = "Hello" ;
70
+ let _ = opt. ok_or ( format ! ( "{} world." , hello) ) ;
67
71
}
68
72
69
73
fn main ( ) { }
Original file line number Diff line number Diff line change @@ -72,5 +72,11 @@ error: use of `unwrap_or` followed by a function call
72
72
LL | let _ = stringy.unwrap_or("".to_owned());
73
73
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
74
74
75
- error: aborting due to 12 previous errors
75
+ error: use of `ok_or` followed by a function call
76
+ --> $DIR/or_fun_call.rs:70:17
77
+ |
78
+ LL | let _ = opt.ok_or(format!("{} world.", hello));
79
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| format!("{} world.", hello))`
80
+
81
+ error: aborting due to 13 previous errors
76
82
You can’t perform that action at this time.
0 commit comments