mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
parent
9897442f27
commit
de24a74b45
@ -64,6 +64,10 @@ fn or_fun_call() {
|
||||
|
||||
let stringy = Some(String::from(""));
|
||||
let _ = stringy.unwrap_or("".to_owned());
|
||||
|
||||
let opt = Some(1);
|
||||
let hello = "Hello";
|
||||
let _ = opt.ok_or(format!("{} world.", hello));
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -72,5 +72,11 @@ error: use of `unwrap_or` followed by a function call
|
||||
LL | let _ = stringy.unwrap_or("".to_owned());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
error: use of `ok_or` followed by a function call
|
||||
--> $DIR/or_fun_call.rs:70:17
|
||||
|
|
||||
LL | let _ = opt.ok_or(format!("{} world.", hello));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| format!("{} world.", hello))`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user