- Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
fn main() { let opt = Some(3); opt.map_or(None, |a| Some(a + 1)); }
Clippy warns like below on this:
| 3 | opt.map_or(None, |a| Some(a + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `and_then` instead: `opt.and_then(|a| Some(a + 1))` |
So I updated it according to the warning:
fn main() { let opt = Some(3); opt.and_then(|a| Some(a + 1)); }
But, Clippy warns like below again:
| 3 | opt.and_then(|a| Some(a + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `opt.map(|a| a + 1)` |
In this case, I want option_map_or_none
to suggest the last code suggested from the beginning.
udzura and pione30
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy