RS.CLIPPY.SINGLE_MATCH

A `match` statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`

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

What it does

Checks for matches with a single arm where an if let will usually suffice.

This intentionally does not lint if there are comments inside of the other arm, so as to allow the user to document why having another explicit pattern with an empty body is necessary, or because the comments need to be preserved for other reasons.

Why is this bad?

Just readability – if let nests less than a match.

Example

match x {
    Some(ref foo) => bar(foo),
    _ => (),
}

Use instead:

if let Some(ref foo) = x {
    bar(foo);
}