]> git.lizzy.rs Git - rust.git/blob - src/docs/match_like_matches_macro.txt
new uninlined_format_args lint to inline explicit arguments
[rust.git] / src / docs / match_like_matches_macro.txt
1 ### What it does
2 Checks for `match`  or `if let` expressions producing a
3 `bool` that could be written using `matches!`
4
5 ### Why is this bad?
6 Readability and needless complexity.
7
8 ### Known problems
9 This lint falsely triggers, if there are arms with
10 `cfg` attributes that remove an arm evaluating to `false`.
11
12 ### Example
13 ```
14 let x = Some(5);
15
16 let a = match x {
17     Some(0) => true,
18     _ => false,
19 };
20
21 let a = if let Some(0) = x {
22     true
23 } else {
24     false
25 };
26 ```
27
28 Use instead:
29 ```
30 let x = Some(5);
31 let a = matches!(x, Some(0));
32 ```