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
I think for all of these cases, clippy already leads you to writing v.first().is_some() through other lints, so maybe it just needs to lint that one case and suggest !v.is_empty()?
Initial impl of `unnecessary_first_then_check`
Fixes#11212
Checks for `{slice/vec/Box<[]>}.first().is_some()` and suggests replacing the unnecessary `Option`-construct with a direct `{slice/...}.is_empty()`. Other lints guide constructs like `if let Some(_) = v.get(0)` into this, which end up as `!v.is_empty()`.
changelog: [`unnecessary_first_then_check`]: Initial implementation
What it does
https://rust-lang.github.io/rust-clippy/master/index.html#/comparison_to
covers things like
string = ""
, but we could also perhaps catch things likeget the first element and check if that's
Someor
None`The text was updated successfully, but these errors were encountered: