RS.CLIPPY.MANUAL_OK_ERR

Find manual implementations of `.ok()` or `.err()` on `Result`

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_err. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for manual implementation of .ok() or .err() on Result values.

Why is this bad?

Using .ok() or .err() rather than a match or if let is less complex and more readable.

Example

let a = match func() {
    Ok(v) => Some(v),
    Err(_) => None,
};
let b = if let Err(v) = func() {
    Some(v)
} else {
    None
};

Use instead:

let a = func().ok();
let b = func().err();