- 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
This is a suggestion for the map_collect_result_unit
lint.
I just refactored this piece of code:
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { for (uuid, err) in self.0.iter() { writeln!(f, "{}: {}", uuid, err)?; } Ok(()) }
into this:
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.iter().map(|(uuid, err)| writeln!(f, "{}: {}", uuid, err)).collect() }
And then the lint told me that I can do
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.iter().try_for_each(|(uuid, err)| writeln!(f, "{}: {}", uuid, err)) }
But maybe it is possible that the lint also tells me that my first version can be written better?
I don't know whether this is possible, but it would be nice to catch the for-loop-version as well here.
Categories (optional)
- Kind:
clippy::style
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints