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
2
--> $DIR/map_unwrap_or.rs:16:13
3
3
|
4
+ LL | let _ = opt.map(|x| x + 1)
5
+ | _____________^
6
+ LL | | // Should lint even though this call is on a separate line.
7
+ LL | | .unwrap_or(0);
8
+ | |_____________________^
9
+ |
10
+ = note: `-D clippy::map-unwrap-or` implied by `-D warnings`
11
+ help: use `map_or(<a>, <f>)` instead
12
+ |
13
+ LL | let _ = opt.map_or(0, |x| x + 1);
14
+ | ^^^^^^ ^^ --
15
+
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_or.rs:20:13
18
+ |
4
19
LL | let _ = opt.map(|x| {
5
20
| _____________^
6
21
LL | | x + 1
7
22
LL | | }
8
23
LL | | ).unwrap_or(0);
9
24
| |__________________^
10
25
|
11
- = note: `-D clippy::map-unwrap-or` implied by `-D warnings`
12
26
help: use `map_or(<a>, <f>)` instead
13
27
|
14
28
LL | let _ = opt.map_or(0, |x| {
@@ -18,7 +32,7 @@ LL | );
18
32
|
19
33
20
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
21
- --> $DIR/map_unwrap_or.rs:20 :13
35
+ --> $DIR/map_unwrap_or.rs:24 :13
22
36
|
23
37
LL | let _ = opt.map(|x| x + 1)
24
38
| _____________^
@@ -35,7 +49,7 @@ LL | }, |x| x + 1);
35
49
|
36
50
37
51
error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
38
- --> $DIR/map_unwrap_or.rs:25 :13
52
+ --> $DIR/map_unwrap_or.rs:29 :13
39
53
|
40
54
LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
41
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -46,7 +60,7 @@ LL | let _ = opt.and_then(|x| Some(x + 1));
46
60
| ^^^^^^^^ --
47
61
48
62
error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
49
- --> $DIR/map_unwrap_or.rs:27 :13
63
+ --> $DIR/map_unwrap_or.rs:31 :13
50
64
|
51
65
LL | let _ = opt.map(|x| {
52
66
| _____________^
@@ -64,7 +78,7 @@ LL | );
64
78
|
65
79
66
80
error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
67
- --> $DIR/map_unwrap_or.rs:31 :13
81
+ --> $DIR/map_unwrap_or.rs:35 :13
68
82
|
69
83
LL | let _ = opt
70
84
| _____________^
@@ -78,7 +92,7 @@ LL | .and_then(|x| Some(x + 1));
78
92
| ^^^^^^^^ --
79
93
80
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
81
- --> $DIR/map_unwrap_or.rs:42 :13
95
+ --> $DIR/map_unwrap_or.rs:46 :13
82
96
|
83
97
LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
84
98
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -89,7 +103,7 @@ LL | let _ = Some("prefix").map_or(id, |p| format!("{}.", p));
89
103
| ^^^^^^ ^^^ --
90
104
91
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
92
- --> $DIR/map_unwrap_or.rs:46 :13
106
+ --> $DIR/map_unwrap_or.rs:50 :13
93
107
|
94
108
LL | let _ = opt.map(|x| {
95
109
| _____________^
@@ -99,7 +113,7 @@ LL | | ).unwrap_or_else(|| 0);
99
113
| |__________________________^
100
114
101
115
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
102
- --> $DIR/map_unwrap_or.rs:50 :13
116
+ --> $DIR/map_unwrap_or.rs:54 :13
103
117
|
104
118
LL | let _ = opt.map(|x| x + 1)
105
119
| _____________^
@@ -108,5 +122,25 @@ LL | | 0
108
122
LL | | );
109
123
| |_________^
110
124
111
- error: aborting due to 8 previous errors
125
+ 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
126
+ --> $DIR/map_unwrap_or.rs:66:13
127
+ |
128
+ LL | let _ = res.map(|x| {
129
+ | _____________^
130
+ LL | | x + 1
131
+ LL | | }
132
+ LL | | ).unwrap_or_else(|_e| 0);
133
+ | |____________________________^
134
+
135
+ 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
136
+ --> $DIR/map_unwrap_or.rs:70:13
137
+ |
138
+ LL | let _ = res.map(|x| x + 1)
139
+ | _____________^
140
+ LL | | .unwrap_or_else(|_e| {
141
+ LL | | 0
142
+ LL | | });
143
+ | |__________^
144
+
145
+ error: aborting due to 11 previous errors
112
146
0 commit comments