RS.CLIPPY.IGNORED_UNIT_PATTERNS
Suggest replacing `_` by `()` in patterns where appropriate
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: ignored_unit_patterns. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of _ in patterns of type ().
Why is this bad?
Matching with () explicitly instead of _ outlines
the fact that the pattern contains no data. Also it
would detect a type change that _ would ignore.
Example
match std::fs::create_dir("tmp-work-dir") {
Ok(_) => println!("Working directory created"),
Err(s) => eprintln!("Could not create directory: {s}"),
}
Use instead:
match std::fs::create_dir("tmp-work-dir") {
Ok(()) => println!("Working directory created"),
Err(s) => eprintln!("Could not create directory: {s}"),
}