RS.CLIPPY.QUESTION_MARK

Checks for expressions that could be replaced by the `?` operator

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

What it does

Checks for expressions that could be replaced by the ? operator.

Why is this bad?

Using the ? operator is shorter and more idiomatic.

Example

if option.is_none() {
    return None;
}

Could be written:

option?;

Configuration

  • msrv: The minimum rust version that the project supports. Defaults to the rust-version field in Cargo.toml

    (default: current version)