mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-17 11:05:20 +00:00
53 lines
1.4 KiB
Plaintext
53 lines
1.4 KiB
Plaintext
error: this pattern can be more concisely encoded with `Option::unwrap_or`
|
|
--> $DIR/less_concise_than.rs:7:5
|
|
|
|
|
LL | / match Some(1) {
|
|
LL | | Some(i) => i,
|
|
LL | | None => 42,
|
|
LL | | };
|
|
| |_____^ help: replace with: `Some(1).unwrap_or(42)`
|
|
|
|
|
= note: `-D clippy::less-concise-than-option-unwrap-or` implied by `-D warnings`
|
|
|
|
error: this pattern can be more concisely encoded with `Option::unwrap_or`
|
|
--> $DIR/less_concise_than.rs:13:5
|
|
|
|
|
LL | / match Some(1) {
|
|
LL | | Some(i) => i,
|
|
LL | | None => 1 + 42,
|
|
LL | | };
|
|
| |_____^ help: replace with: `Some(1).unwrap_or_else(|| 1 + 42)`
|
|
|
|
error: this pattern can be more concisely encoded with `Option::unwrap_or`
|
|
--> $DIR/less_concise_than.rs:19:5
|
|
|
|
|
LL | / match Some(1) {
|
|
LL | | Some(i) => i,
|
|
LL | | None => {
|
|
LL | | let a = 1 + 42;
|
|
... |
|
|
LL | | },
|
|
LL | | };
|
|
| |_____^
|
|
|
|
|
help: replace with
|
|
|
|
|
LL | Some(1).unwrap_or_else(|| {
|
|
LL | let a = 1 + 42;
|
|
LL | let b = a + 42;
|
|
LL | b + 42
|
|
LL | });
|
|
|
|
|
|
|
error: this pattern can be more concisely encoded with `Option::unwrap_or`
|
|
--> $DIR/less_concise_than.rs:29:5
|
|
|
|
|
LL | / match Some("Bob") {
|
|
LL | | Some(i) => i,
|
|
LL | | None => "Alice",
|
|
LL | | };
|
|
| |_____^ help: replace with: `Some("Bob").unwrap_or("Alice")`
|
|
|
|
error: aborting due to 4 previous errors
|
|
|