-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
Detects usage of map(..).unwrap()
Categories (optional)
Kind: pedantic
What is the advantage of the recommended code over the original code
The unwrap effectively only applies to the value before .map(..), so putting it after .map(..) needlessly complicates the semantics of the code.
Drawbacks
None.
Example
opt.map(|n| n * 2).unwrap()Could be written as:
opt.unwrap() * 2This should also work with expect as well as maybe other Option and Result transformers like filter.
I think the name map_unwrap is good, even though other method combinations are applicable.
jplatte, kyoto7250 and lengyijun
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints