-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
Suggest using try_for_each
instead of map(...).collect()
whenever possible.
More specifically, detect code in the following form:
iter.map(/* anything that returns Result<(), _> */).collect::<Result<(), _>>()
Categories (optional)
- Kind: clippy::style
What is the advantage of the recommended code over the original code
It is easier to read and more idiomatic
Drawbacks
None.
Example
iter.map(|t| Err(t)).collect::<Result<(), _>>()
Could be written as:
iter.try_for_each(|t| Err(t))
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints