-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
A-lintArea: New lintsArea: New lintsL-complexityLint: Belongs in the complexity lint groupLint: Belongs in the complexity lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Inspired by the change made in https://github.com/rust-lang/rust/pull/69022/files#diff-d1ff3aad2daeb77432493d91c41b722bL147
When an inspect
is followed by for_each
, that's the same as just doing the thing in the inspect at the beginning of the closure in the for_each.
It's possible that this should only be suggested when a brace-bodied closure is already being passed to for_each, like
.inspect(|x| do_something(x, 2))
.for_each(|x| {
do_more(x);
update_something(x);
});
which can just be
.for_each(|x| {
do_something(x, 2);
do_more(x);
update_something(x);
});
But not for something like .inspect(foo).for_each(bar)
, where it's not obvious that the closure is better. (It's not bad, but not an obvious improvement.)
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsL-complexityLint: Belongs in the complexity lint groupLint: Belongs in the complexity lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy