RS.CLIPPY.MANUAL_OK_OR
Finds patterns that can be encoded more concisely with `Option::ok_or`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: manual_ok_or. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Finds patterns that reimplement Option::ok_or.
Why is this bad?
Concise code helps focusing on behavior instead of boilerplate.
Examples
let foo: Option<i32> = None;
foo.map_or(Err("error"), |v| Ok(v));
Use instead:
let foo: Option<i32> = None;
foo.ok_or("error");