RS.CLIPPY.SEARCH_IS_SOME

Using an iterator or string search followed by `is_some()` or `is_none()`, which is more succinctly expressed as a call to `any()` or `contains()` (with negation in case of `is_none()`)

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: search_is_some. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for an iterator or string search (such as find(), position(), or rposition()) followed by a call to is_some() or is_none().

Why is this bad?

Readability, this can be written more concisely as:

  • _.any(_), or _.contains(_) for is_some(),
  • !_.any(_), or !_.contains(_) for is_none().

Example

let vec = vec![1];
vec.iter().find(|x| **x == 0).is_some();

"hello world".find("world").is_none();

Use instead:

let vec = vec![1];
vec.iter().any(|x| *x == 0);

!"hello world".contains("world");