diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/src/docs/map_flatten.txt | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/src/tools/clippy/src/docs/map_flatten.txt b/src/tools/clippy/src/docs/map_flatten.txt deleted file mode 100644 index 73c0e5140..000000000 --- a/src/tools/clippy/src/docs/map_flatten.txt +++ /dev/null @@ -1,21 +0,0 @@ -### What it does -Checks for usage of `_.map(_).flatten(_)` on `Iterator` and `Option` - -### Why is this bad? -Readability, this can be written more concisely as -`_.flat_map(_)` for `Iterator` or `_.and_then(_)` for `Option` - -### Example -``` -let vec = vec![vec![1]]; -let opt = Some(5); - -vec.iter().map(|x| x.iter()).flatten(); -opt.map(|x| Some(x * 2)).flatten(); -``` - -Use instead: -``` -vec.iter().flat_map(|x| x.iter()); -opt.and_then(|x| Some(x * 2)); -```
\ No newline at end of file |