RS.CLIPPY.OPTION_MAP_OR_NONE

Using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`

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

What it does

Checks for usage of _.map_or(None, _).

Why is this bad?

Readability, this can be written more concisely as _.and_then(_).

Known problems

The order of the arguments is not in execution order.

Example

opt.map_or(None, |a| Some(a + 1));

Use instead:

opt.and_then(|a| Some(a + 1));