blob: a65d8f75ddd2a2952c22954aa02e15a07beb26be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
error: called `map(..).flatten()` on `Option`
--> $DIR/map_flatten.rs:8:10
|
LL | .map(|x| {
| __________^
LL | |
LL | |
LL | | if x <= 5 {
... |
LL | | })
LL | | .flatten();
| |__________________^
|
= note: `-D clippy::map-flatten` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::map_flatten)]`
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
LL ~ .and_then(|x| {
LL +
LL +
LL + if x <= 5 {
LL + Some(x)
LL + } else {
LL + None
LL + }
LL ~ });
|
error: called `map(..).flatten()` on `Result`
--> $DIR/map_flatten.rs:20:10
|
LL | .map(|x| {
| __________^
LL | |
LL | | if x == 1 {
LL | | Ok(x)
... |
LL | | })
LL | | .flatten();
| |__________________^
|
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
LL ~ .and_then(|x| {
LL +
LL + if x == 1 {
LL + Ok(x)
LL + } else {
LL + Err(0)
LL + }
LL ~ });
|
error: called `map(..).flatten()` on `Result`
--> $DIR/map_flatten.rs:33:10
|
LL | .map(|res| {
| __________^
LL | |
LL | | if res > 0 {
LL | | do_something();
... |
LL | | })
LL | | .flatten();
| |__________________^
|
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
LL ~ .and_then(|res| {
LL +
LL + if res > 0 {
LL + do_something();
LL + Ok(res)
LL + } else {
LL + Err(0)
LL + }
LL ~ });
|
error: called `map(..).flatten()` on `Iterator`
--> $DIR/map_flatten.rs:46:10
|
LL | .map(|some_value| {
| __________^
LL | |
LL | | if some_value > 3 {
LL | | Some(some_value)
... |
LL | | })
LL | | .flatten()
| |__________________^
|
help: try replacing `map` with `filter_map` and remove the `.flatten()`
|
LL ~ .filter_map(|some_value| {
LL +
LL + if some_value > 3 {
LL + Some(some_value)
LL + } else {
LL + None
LL + }
LL + })
|
error: aborting due to 4 previous errors
|