RS.CLIPPY.UNNECESSARY_GET_THEN_CHECK
Calling `.get().is_some()` or `.get().is_none()` instead of `.contains()` or `.contains_key()`
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_get_then_check. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks the usage of .get().is_some() or .get().is_none() on std map types.
Why is this bad?
It can be done in one call with .contains()/.contains_key().
Example
let s: HashSet<String> = HashSet::new();
if s.get("a").is_some() {
// code
}
Use instead:
let s: HashSet<String> = HashSet::new();
if s.contains("a") {
// code
}