Add test for or_fun_call macro suggestion

Closes #1018
This commit is contained in:
Philipp Hansch 2019-04-24 08:11:20 +02:00
parent 9897442f27
commit de24a74b45
No known key found for this signature in database
GPG Key ID: 82AA61CAA11397E6
2 changed files with 11 additions and 1 deletions

View File

@ -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() {}

View File

@ -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