manual_unwrap_or / use consts::constant_simple helper

This commit is contained in:
Tim Nielens 2020-10-12 00:06:21 +02:00
parent 6d4eeeabcd
commit fc846c37fc
3 changed files with 10 additions and 7 deletions

View file

@ -9,7 +9,7 @@ fn unwrap_or() {
Some(1).unwrap_or(42);
// richer none expr
Some(1).unwrap_or_else(|| 1 + 42);
Some(1).unwrap_or(1 + 42);
// multiline case
Some(1).unwrap_or_else(|| {

View file

@ -18,14 +18,14 @@ LL | | Some(i) => i,
LL | | };
| |_____^ help: replace with: `Some(1).unwrap_or(42)`
error: this pattern reimplements `Option::unwrap_or_else`
error: this pattern reimplements `Option::unwrap_or`
--> $DIR/manual_unwrap_or.rs:18:5
|
LL | / match Some(1) {
LL | | Some(i) => i,
LL | | None => 1 + 42,
LL | | };
| |_____^ help: replace with: `Some(1).unwrap_or_else(|| 1 + 42)`
| |_____^ help: replace with: `Some(1).unwrap_or(1 + 42)`
error: this pattern reimplements `Option::unwrap_or_else`
--> $DIR/manual_unwrap_or.rs:24:5