File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 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() {
6464
6565 let stringy = Some ( String :: from ( "" ) ) ;
6666 let _ = stringy. unwrap_or ( "" . to_owned ( ) ) ;
67+
68+ let opt = Some ( 1 ) ;
69+ let hello = "Hello" ;
70+ let _ = opt. ok_or ( format ! ( "{} world." , hello) ) ;
6771}
6872
6973fn 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
7272LL | let _ = stringy.unwrap_or("".to_owned());
7373 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
7474
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
7682
You can’t perform that action at this time.
0 commit comments