You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace std::iter::Empty::default() with std::iter::empty().
These two are equivalent, but one should be preferred: iter::empty requires learning less of the API than iter::Empty::default and it's also simpler.
I actually made this mistake consistently in a PR, it seems silly, but it happens! I caught this during code review and thought, hey, clippy should be able to detect that.
Lint Name
iter-empty-not-iter-empty-default
Category
style
Advantage
It's shorter
Rust generally discourages you from knowing the concrete type of an iterator combinator, e.g. you shouldn't really need to know Map or Empty, instead you should just call the map() and empty() functions. If you need to name the output type you should use impl Iterator instead.
Drawbacks
No response
Example
let x = std::iter::Empty::default();
Could be written as:
let x = std::iter::empty();
The text was updated successfully, but these errors were encountered:
What it does
Replace
std::iter::Empty::default()
withstd::iter::empty()
.These two are equivalent, but one should be preferred:
iter::empty
requires learning less of the API thaniter::Empty::default
and it's also simpler.I actually made this mistake consistently in a PR, it seems silly, but it happens! I caught this during code review and thought, hey, clippy should be able to detect that.
Lint Name
iter-empty-not-iter-empty-default
Category
style
Advantage
impl Iterator
instead.Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: