RS.CLIPPY.ITER_FILTER_IS_OK
Filtering an iterator over `Result`s for `Ok` can be achieved with `flatten`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: iter_filter_is_ok. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of .filter(Result::is_ok) that may be replaced with a .flatten() call.
This lint will require additional changes to the follow-up calls as it affects the type.
Why is this bad?
This pattern is often followed by manual unwrapping of Result. The simplification
results in more readable and succinct code without the need for manual unwrapping.
Example
vec![Ok::<i32, String>(1)].into_iter().filter(Result::is_ok);
Use instead:
vec![Ok::<i32, String>(1)].into_iter().flatten();