]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/single_match.txt
Rollup merge of #102470 - est31:stabilize_const_char_convert, r=joshtriplett
[rust.git] / src / tools / clippy / src / docs / single_match.txt
1 ### What it does
2 Checks for matches with a single arm where an `if let`
3 will usually suffice.
4
5 ### Why is this bad?
6 Just readability – `if let` nests less than a `match`.
7
8 ### Example
9 ```
10 match x {
11     Some(ref foo) => bar(foo),
12     _ => (),
13 }
14 ```
15
16 Use instead:
17 ```
18 if let Some(ref foo) = x {
19     bar(foo);
20 }
21 ```