Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test case for option_map_or_none
- Loading branch information
1 parent
2ed4a8a
commit 4f71ff3
Showing
3 changed files
with
27 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead | ||
--> $DIR/option_map_or_none.rs:10:13 | ||
| | ||
LL | let _ = opt.map_or(None, |x| Some(x + 1)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `map` instead: `opt.map(|x| Some(x + 1))` | ||
LL | let _ :Option<i32> = opt.map_or(None, |x| Some(x + 1)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `map` instead: `opt.map(|x| x + 1)` | ||
| | ||
= note: `-D clippy::option-map-or-none` implied by `-D warnings` | ||
|
||
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead | ||
--> $DIR/option_map_or_none.rs:13:13 | ||
| | ||
LL | let _ = opt.map_or(None, |x| { | ||
LL | let _ :Option<i32> = opt.map_or(None, |x| { | ||
| _____________^ | ||
LL | | Some(x + 1) | ||
LL | | }); | ||
| |_________________________^ | ||
| | ||
help: try using `map` instead | ||
| | ||
LL ~ let _ = opt.map(|x| { | ||
LL + Some(x + 1) | ||
LL ~ let _ :Option<i32> = opt.map(|x| { | ||
LL + x + 1 | ||
LL ~ }); | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead | ||
--> $DIR/option_map_or_none.rs:20:26 | ||
| | ||
LL | let _ :Option<i32> = opt.map_or(None, bar); | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: try using `and_then` instead: `opt.and_then(bar)` | ||
|
||
error: aborting due to 3 previous errors | ||
|