RS.CLIPPY.UNNECESSARY_FIRST_THEN_CHECK
Calling `.first().is_some()` or `.first().is_none()` instead of `.is_empty()`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: unnecessary_first_then_check. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks the usage of .first().is_some() or .first().is_none() to check if a slice is
empty.
Why is this bad?
Using .is_empty() is shorter and better communicates the intention.
Example
let v = vec![1, 2, 3];
if v.first().is_none() {
// The vector is empty...
}
Use instead:
let v = vec![1, 2, 3];
if v.is_empty() {
// The vector is empty...
}