diff options
Diffstat (limited to 'src/tools/clippy/src/docs/single_match.txt')
-rw-r--r-- | src/tools/clippy/src/docs/single_match.txt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/single_match.txt b/src/tools/clippy/src/docs/single_match.txt new file mode 100644 index 000000000..31dde4da8 --- /dev/null +++ b/src/tools/clippy/src/docs/single_match.txt @@ -0,0 +1,21 @@ +### What it does +Checks for matches with a single arm where an `if let` +will usually suffice. + +### 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); +} +```
\ No newline at end of file |