1
1
error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
2
- --> $DIR/map_unwrap .rs:17:13
2
+ --> $DIR/map_unwrap_or .rs:17:13
3
3
|
4
4
LL | let _ = opt.map(|x| x + 1)
5
5
| _____________^
6
6
LL | | // Should lint even though this call is on a separate line.
7
7
LL | | .unwrap_or(0);
8
8
| |_____________________^
9
9
|
10
- = note: `-D clippy::map-unwrap` implied by `-D warnings`
10
+ = note: `-D clippy::map-unwrap-or ` implied by `-D warnings`
11
11
help: use `map_or(a, f)` instead
12
12
|
13
13
LL | let _ = opt.map_or(0, |x| x + 1);
14
14
| ^^^^^^ ^^ --
15
15
16
16
error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
17
- --> $DIR/map_unwrap .rs:21:13
17
+ --> $DIR/map_unwrap_or .rs:21:13
18
18
|
19
19
LL | let _ = opt.map(|x| {
20
20
| _____________^
@@ -32,7 +32,7 @@ LL | );
32
32
|
33
33
34
34
error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
35
- --> $DIR/map_unwrap .rs:25:13
35
+ --> $DIR/map_unwrap_or .rs:25:13
36
36
|
37
37
LL | let _ = opt.map(|x| x + 1)
38
38
| _____________^
@@ -49,7 +49,7 @@ LL | }, |x| x + 1);
49
49
|
50
50
51
51
error: called `map(f).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(f)` instead
52
- --> $DIR/map_unwrap .rs:30:13
52
+ --> $DIR/map_unwrap_or .rs:30:13
53
53
|
54
54
LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
55
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -60,7 +60,7 @@ LL | let _ = opt.and_then(|x| Some(x + 1));
60
60
| ^^^^^^^^ --
61
61
62
62
error: called `map(f).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(f)` instead
63
- --> $DIR/map_unwrap .rs:32:13
63
+ --> $DIR/map_unwrap_or .rs:32:13
64
64
|
65
65
LL | let _ = opt.map(|x| {
66
66
| _____________^
@@ -78,7 +78,7 @@ LL | );
78
78
|
79
79
80
80
error: called `map(f).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(f)` instead
81
- --> $DIR/map_unwrap .rs:36:13
81
+ --> $DIR/map_unwrap_or .rs:36:13
82
82
|
83
83
LL | let _ = opt
84
84
| _____________^
@@ -92,7 +92,7 @@ LL | .and_then(|x| Some(x + 1));
92
92
| ^^^^^^^^ --
93
93
94
94
error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
95
- --> $DIR/map_unwrap .rs:47:13
95
+ --> $DIR/map_unwrap_or .rs:47:13
96
96
|
97
97
LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
98
98
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -103,7 +103,7 @@ LL | let _ = Some("prefix").map_or(id, |p| format!("{}.", p));
103
103
| ^^^^^^ ^^^ --
104
104
105
105
error: called `map(f).unwrap_or_else(g)` on an `Option` value. This can be done more directly by calling `map_or_else(g, f)` instead
106
- --> $DIR/map_unwrap .rs:51:13
106
+ --> $DIR/map_unwrap_or .rs:51:13
107
107
|
108
108
LL | let _ = opt.map(|x| x + 1)
109
109
| _____________^
@@ -114,7 +114,7 @@ LL | | .unwrap_or_else(|| 0);
114
114
= note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
115
115
116
116
error: called `map(f).unwrap_or_else(g)` on an `Option` value. This can be done more directly by calling `map_or_else(g, f)` instead
117
- --> $DIR/map_unwrap .rs:55:13
117
+ --> $DIR/map_unwrap_or .rs:55:13
118
118
|
119
119
LL | let _ = opt.map(|x| {
120
120
| _____________^
@@ -124,7 +124,7 @@ LL | | ).unwrap_or_else(|| 0);
124
124
| |__________________________^
125
125
126
126
error: called `map(f).unwrap_or_else(g)` on an `Option` value. This can be done more directly by calling `map_or_else(g, f)` instead
127
- --> $DIR/map_unwrap .rs:59:13
127
+ --> $DIR/map_unwrap_or .rs:59:13
128
128
|
129
129
LL | let _ = opt.map(|x| x + 1)
130
130
| _____________^
@@ -134,23 +134,23 @@ LL | | );
134
134
| |_________^
135
135
136
136
error: called `map(f).unwrap_or_else(g)` on a `Result` value. This can be done more directly by calling `.map_or_else(g, f)` instead
137
- --> $DIR/map_unwrap .rs:88:13
137
+ --> $DIR/map_unwrap_or .rs:88:13
138
138
|
139
139
LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
140
140
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
141
141
|
142
142
= note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `map_or_else(|e| 0, |x| x + 1)`
143
143
144
144
error: called `map(f).unwrap_or_else(g)` on a `Result` value. This can be done more directly by calling `.map_or_else(g, f)` instead
145
- --> $DIR/map_unwrap .rs:90:13
145
+ --> $DIR/map_unwrap_or .rs:90:13
146
146
|
147
147
LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
148
148
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
149
149
|
150
150
= note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `map_or_else(|e| 0, |x| x + 1)`
151
151
152
152
error: called `map(f).unwrap_or_else(g)` on a `Result` value. This can be done more directly by calling `.map_or_else(g, f)` instead
153
- --> $DIR/map_unwrap .rs:91:13
153
+ --> $DIR/map_unwrap_or .rs:91:13
154
154
|
155
155
LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
156
156
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments