suggest using if let Some(x) = arr.first()
over if !arr.is_empty() then arr[0]
#11858
Labels
A-lint
Area: New lints
What it does
Well, exactly as the title described, and could apply to
while
s as well.The idea is kinda like a combination of [
unnecessary_unwrap
] and [get_first
].Such lint might already exist, idk.
Advantage
Readability?
Drawbacks
maybe? maybe not?
Example
Could be written as:
The text was updated successfully, but these errors were encountered: