RS.CLIPPY.UNNECESSARY_LITERAL_UNWRAP

Using `unwrap()` related calls on `Result` and `Option` constructors

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

What it does

Checks for .unwrap() related calls on Results and Options that are constructed.

Why is this bad?

It is better to write the value directly without the indirection.

Examples

let val1 = Some(1).unwrap();
let val2 = Ok::<_, ()>(1).unwrap();
let val3 = Err::<(), _>(1).unwrap_err();

Use instead:

let val1 = 1;
let val2 = 1;
let val3 = 1;