RS.CLIPPY.OR_THEN_UNWRAP

Checks for `.or(…).unwrap()` calls to Options and Results.

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

What it does

Checks for .or(...).unwrap() calls to Options and Results.

Why is this bad?

You should use .unwrap_or(...) instead for clarity.

Example

// Result
let value = result.or::<Error>(Ok(fallback)).unwrap();

// Option
let value = option.or(Some(fallback)).unwrap();

Use instead:

// Result
let value = result.unwrap_or(fallback);

// Option
let value = option.unwrap_or(fallback);