Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit fd629c0

Browse files
committed
check method
1 parent 3953c53 commit fd629c0

File tree

5 files changed

+98
-17
lines changed

5 files changed

+98
-17
lines changed

clippy_lints/src/use_retain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn check_iter(
102102
if_chain! {
103103
if let hir::ExprKind::MethodCall(_, [filter_expr], _) = &target_expr.kind;
104104
if let Some(copied_def_id) = cx.typeck_results().type_dependent_def_id(target_expr.hir_id);
105-
if match_def_path(cx, copied_def_id, &paths::CORE_ITER_COPIED);
105+
if match_def_path(cx, copied_def_id, &paths::CORE_ITER_COPIED) || match_def_path(cx, copied_def_id, &paths::CORE_ITER_CLONED);
106106

107107
if let hir::ExprKind::MethodCall(_, [iter_expr, _], _) = &filter_expr.kind;
108108
if let Some(filter_def_id) = cx.typeck_results().type_dependent_def_id(filter_expr.hir_id);

clippy_utils/src/paths.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub const BTREESET_ITER: [&str; 6] = ["alloc", "collections", "btree", "set", "B
2525
pub const CLONE_TRAIT_METHOD: [&str; 4] = ["core", "clone", "Clone", "clone"];
2626
pub const COW: [&str; 3] = ["alloc", "borrow", "Cow"];
2727
pub const CORE_ITER_COLLECT: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "collect"];
28+
pub const CORE_ITER_CLONED: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "cloned"];
2829
pub const CORE_ITER_COPIED: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "copied"];
2930
pub const CORE_ITER_FILTER: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "filter"];
3031
pub const CORE_ITER_INTO_ITER: [&str; 6] = ["core", "iter", "traits", "collect", "IntoIterator", "into_iter"];

tests/ui/use_retain.fixed

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ fn binary_heap_retain() {
2525
let mut heap = BinaryHeap::from([1, 2, 3]);
2626
heap = heap.into_iter().filter(|x| x % 2 == 0).collect();
2727
heap = heap.iter().filter(|&x| x % 2 == 0).copied().collect();
28+
heap = heap.iter().filter(|&x| x % 2 == 0).cloned().collect();
2829

2930
// Do not lint, because type conversion is performed
3031
heap = heap.into_iter().filter(|x| x % 2 == 0).collect::<BinaryHeap<i8>>();
3132
heap = heap.iter().filter(|&x| x % 2 == 0).copied().collect::<BinaryHeap<i8>>();
33+
heap = heap.iter().filter(|&x| x % 2 == 0).cloned().collect::<BinaryHeap<i8>>();
3234

3335
// Do not lint, because this expression is not assign.
3436
let mut bar: BinaryHeap<i8> = heap.iter().filter(|&x| x % 2 == 0).copied().collect();
@@ -65,6 +67,7 @@ fn btree_set_retain() {
6567
// Do lint.
6668
btree_set.retain(|x| x % 2 == 0);
6769
btree_set.retain(|x| x % 2 == 0);
70+
btree_set.retain(|x| x % 2 == 0);
6871

6972
// Do not lint, because type conversion is performed
7073
btree_set = btree_set
@@ -73,6 +76,12 @@ fn btree_set_retain() {
7376
.copied()
7477
.collect::<BTreeSet<i8>>();
7578

79+
btree_set = btree_set
80+
.iter()
81+
.filter(|&x| x % 2 == 0)
82+
.cloned()
83+
.collect::<BTreeSet<i8>>();
84+
7685
btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect::<BTreeSet<i8>>();
7786

7887
// Do not lint, because this expression is not assign.
@@ -81,6 +90,7 @@ fn btree_set_retain() {
8190

8291
// Do not lint, because it is an assignment to a different variable.
8392
bar = foobar.iter().filter(|&x| x % 2 == 0).copied().collect();
93+
bar = foobar.iter().filter(|&x| x % 2 == 0).cloned().collect();
8494
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
8595
}
8696

@@ -109,6 +119,7 @@ fn hash_set_retain() {
109119
// Do lint.
110120
hash_set.retain(|x| x % 2 == 0);
111121
hash_set.retain(|x| x % 2 == 0);
122+
hash_set.retain(|x| x % 2 == 0);
112123

113124
// Do not lint, because type conversion is performed
114125
hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect::<HashSet<i8>>();
@@ -118,12 +129,19 @@ fn hash_set_retain() {
118129
.copied()
119130
.collect::<HashSet<i8>>();
120131

132+
hash_set = hash_set
133+
.iter()
134+
.filter(|&x| x % 2 == 0)
135+
.cloned()
136+
.collect::<HashSet<i8>>();
137+
121138
// Do not lint, because this expression is not assign.
122139
let mut bar: HashSet<i8> = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect();
123140
let mut foobar: HashSet<i8> = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
124141

125142
// Do not lint, because it is an assignment to a different variable.
126143
bar = foobar.iter().filter(|&x| x % 2 == 0).copied().collect();
144+
bar = foobar.iter().filter(|&x| x % 2 == 0).cloned().collect();
127145
bar = foobar.into_iter().filter(|&x| x % 2 == 0).collect();
128146
}
129147

@@ -144,17 +162,20 @@ fn vec_retain() {
144162
// Do lint.
145163
vec.retain(|x| x % 2 == 0);
146164
vec.retain(|x| x % 2 == 0);
165+
vec.retain(|x| x % 2 == 0);
147166

148167
// Do not lint, because type conversion is performed
149168
vec = vec.into_iter().filter(|x| x % 2 == 0).collect::<Vec<i8>>();
150169
vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect::<Vec<i8>>();
170+
vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect::<Vec<i8>>();
151171

152172
// Do not lint, because this expression is not assign.
153173
let mut bar: Vec<i8> = vec.iter().filter(|&x| x % 2 == 0).copied().collect();
154174
let mut foobar: Vec<i8> = vec.into_iter().filter(|x| x % 2 == 0).collect();
155175

156176
// Do not lint, because it is an assignment to a different variable.
157177
bar = foobar.iter().filter(|&x| x % 2 == 0).copied().collect();
178+
bar = foobar.iter().filter(|&x| x % 2 == 0).cloned().collect();
158179
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
159180
}
160181

@@ -165,13 +186,19 @@ fn vec_queue_retain() {
165186
// Do lint.
166187
vec_deque.retain(|x| x % 2 == 0);
167188
vec_deque.retain(|x| x % 2 == 0);
189+
vec_deque.retain(|x| x % 2 == 0);
168190

169191
// Do not lint, because type conversion is performed
170192
vec_deque = vec_deque
171193
.iter()
172194
.filter(|&x| x % 2 == 0)
173195
.copied()
174196
.collect::<VecDeque<i8>>();
197+
vec_deque = vec_deque
198+
.iter()
199+
.filter(|&x| x % 2 == 0)
200+
.cloned()
201+
.collect::<VecDeque<i8>>();
175202
vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect::<VecDeque<i8>>();
176203

177204
// Do not lint, because this expression is not assign.
@@ -180,5 +207,6 @@ fn vec_queue_retain() {
180207

181208
// Do not lint, because it is an assignment to a different variable.
182209
bar = foobar.iter().filter(|&x| x % 2 == 0).copied().collect();
210+
bar = foobar.iter().filter(|&x| x % 2 == 0).cloned().collect();
183211
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
184212
}

tests/ui/use_retain.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ fn binary_heap_retain() {
2525
let mut heap = BinaryHeap::from([1, 2, 3]);
2626
heap = heap.into_iter().filter(|x| x % 2 == 0).collect();
2727
heap = heap.iter().filter(|&x| x % 2 == 0).copied().collect();
28+
heap = heap.iter().filter(|&x| x % 2 == 0).cloned().collect();
2829

2930
// Do not lint, because type conversion is performed
3031
heap = heap.into_iter().filter(|x| x % 2 == 0).collect::<BinaryHeap<i8>>();
3132
heap = heap.iter().filter(|&x| x % 2 == 0).copied().collect::<BinaryHeap<i8>>();
33+
heap = heap.iter().filter(|&x| x % 2 == 0).cloned().collect::<BinaryHeap<i8>>();
3234

3335
// Do not lint, because this expression is not assign.
3436
let mut bar: BinaryHeap<i8> = heap.iter().filter(|&x| x % 2 == 0).copied().collect();
@@ -67,6 +69,7 @@ fn btree_set_retain() {
6769

6870
// Do lint.
6971
btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect();
72+
btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
7073
btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect();
7174

7275
// Do not lint, because type conversion is performed
@@ -76,6 +79,12 @@ fn btree_set_retain() {
7679
.copied()
7780
.collect::<BTreeSet<i8>>();
7881

82+
btree_set = btree_set
83+
.iter()
84+
.filter(|&x| x % 2 == 0)
85+
.cloned()
86+
.collect::<BTreeSet<i8>>();
87+
7988
btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect::<BTreeSet<i8>>();
8089

8190
// Do not lint, because this expression is not assign.
@@ -84,6 +93,7 @@ fn btree_set_retain() {
8493

8594
// Do not lint, because it is an assignment to a different variable.
8695
bar = foobar.iter().filter(|&x| x % 2 == 0).copied().collect();
96+
bar = foobar.iter().filter(|&x| x % 2 == 0).cloned().collect();
8797
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
8898
}
8999

@@ -115,6 +125,7 @@ fn hash_set_retain() {
115125
// Do lint.
116126
hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
117127
hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect();
128+
hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
118129

119130
// Do not lint, because type conversion is performed
120131
hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect::<HashSet<i8>>();
@@ -124,12 +135,19 @@ fn hash_set_retain() {
124135
.copied()
125136
.collect::<HashSet<i8>>();
126137

138+
hash_set = hash_set
139+
.iter()
140+
.filter(|&x| x % 2 == 0)
141+
.cloned()
142+
.collect::<HashSet<i8>>();
143+
127144
// Do not lint, because this expression is not assign.
128145
let mut bar: HashSet<i8> = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect();
129146
let mut foobar: HashSet<i8> = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
130147

131148
// Do not lint, because it is an assignment to a different variable.
132149
bar = foobar.iter().filter(|&x| x % 2 == 0).copied().collect();
150+
bar = foobar.iter().filter(|&x| x % 2 == 0).cloned().collect();
133151
bar = foobar.into_iter().filter(|&x| x % 2 == 0).collect();
134152
}
135153

@@ -149,18 +167,21 @@ fn vec_retain() {
149167
let mut vec = vec![0, 1, 2];
150168
// Do lint.
151169
vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect();
170+
vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect();
152171
vec = vec.into_iter().filter(|x| x % 2 == 0).collect();
153172

154173
// Do not lint, because type conversion is performed
155174
vec = vec.into_iter().filter(|x| x % 2 == 0).collect::<Vec<i8>>();
156175
vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect::<Vec<i8>>();
176+
vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect::<Vec<i8>>();
157177

158178
// Do not lint, because this expression is not assign.
159179
let mut bar: Vec<i8> = vec.iter().filter(|&x| x % 2 == 0).copied().collect();
160180
let mut foobar: Vec<i8> = vec.into_iter().filter(|x| x % 2 == 0).collect();
161181

162182
// Do not lint, because it is an assignment to a different variable.
163183
bar = foobar.iter().filter(|&x| x % 2 == 0).copied().collect();
184+
bar = foobar.iter().filter(|&x| x % 2 == 0).cloned().collect();
164185
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
165186
}
166187

@@ -170,6 +191,7 @@ fn vec_queue_retain() {
170191

171192
// Do lint.
172193
vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect();
194+
vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect();
173195
vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect();
174196

175197
// Do not lint, because type conversion is performed
@@ -178,6 +200,11 @@ fn vec_queue_retain() {
178200
.filter(|&x| x % 2 == 0)
179201
.copied()
180202
.collect::<VecDeque<i8>>();
203+
vec_deque = vec_deque
204+
.iter()
205+
.filter(|&x| x % 2 == 0)
206+
.cloned()
207+
.collect::<VecDeque<i8>>();
181208
vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect::<VecDeque<i8>>();
182209

183210
// Do not lint, because this expression is not assign.
@@ -186,5 +213,6 @@ fn vec_queue_retain() {
186213

187214
// Do not lint, because it is an assignment to a different variable.
188215
bar = foobar.iter().filter(|&x| x % 2 == 0).copied().collect();
216+
bar = foobar.iter().filter(|&x| x % 2 == 0).cloned().collect();
189217
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
190218
}

tests/ui/use_retain.stderr

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
error: this expression can be written more simply using `.retain()`
2-
--> $DIR/use_retain.rs:45:5
2+
--> $DIR/use_retain.rs:47:5
33
|
44
LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|k, _| k % 2 == 0)`
66
|
77
= note: `-D clippy::use-retain` implied by `-D warnings`
88

99
error: this expression can be written more simply using `.retain()`
10-
--> $DIR/use_retain.rs:46:5
10+
--> $DIR/use_retain.rs:48:5
1111
|
1212
LL | btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect();
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|_, &mut v| v % 2 == 0)`
1414

1515
error: this expression can be written more simply using `.retain()`
16-
--> $DIR/use_retain.rs:47:5
16+
--> $DIR/use_retain.rs:49:5
1717
|
1818
LL | / btree_map = btree_map
1919
LL | | .into_iter()
@@ -22,31 +22,37 @@ LL | | .collect();
2222
| |__________________^ help: consider calling `.retain()` instead: `btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))`
2323

2424
error: this expression can be written more simply using `.retain()`
25-
--> $DIR/use_retain.rs:69:5
25+
--> $DIR/use_retain.rs:71:5
2626
|
2727
LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect();
2828
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
2929

3030
error: this expression can be written more simply using `.retain()`
31-
--> $DIR/use_retain.rs:70:5
31+
--> $DIR/use_retain.rs:72:5
32+
|
33+
LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
35+
36+
error: this expression can be written more simply using `.retain()`
37+
--> $DIR/use_retain.rs:73:5
3238
|
3339
LL | btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect();
3440
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
3541

3642
error: this expression can be written more simply using `.retain()`
37-
--> $DIR/use_retain.rs:93:5
43+
--> $DIR/use_retain.rs:103:5
3844
|
3945
LL | hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
4046
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|k, _| k % 2 == 0)`
4147

4248
error: this expression can be written more simply using `.retain()`
43-
--> $DIR/use_retain.rs:94:5
49+
--> $DIR/use_retain.rs:104:5
4450
|
4551
LL | hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect();
4652
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|_, &mut v| v % 2 == 0)`
4753

4854
error: this expression can be written more simply using `.retain()`
49-
--> $DIR/use_retain.rs:95:5
55+
--> $DIR/use_retain.rs:105:5
5056
|
5157
LL | / hash_map = hash_map
5258
LL | | .into_iter()
@@ -55,46 +61,64 @@ LL | | .collect();
5561
| |__________________^ help: consider calling `.retain()` instead: `hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))`
5662

5763
error: this expression can be written more simply using `.retain()`
58-
--> $DIR/use_retain.rs:116:5
64+
--> $DIR/use_retain.rs:126:5
5965
|
6066
LL | hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
6167
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
6268

6369
error: this expression can be written more simply using `.retain()`
64-
--> $DIR/use_retain.rs:117:5
70+
--> $DIR/use_retain.rs:127:5
6571
|
6672
LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect();
6773
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
6874

6975
error: this expression can be written more simply using `.retain()`
70-
--> $DIR/use_retain.rs:139:5
76+
--> $DIR/use_retain.rs:128:5
77+
|
78+
LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
79+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
80+
81+
error: this expression can be written more simply using `.retain()`
82+
--> $DIR/use_retain.rs:157:5
7183
|
7284
LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect();
7385
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')`
7486

7587
error: this expression can be written more simply using `.retain()`
76-
--> $DIR/use_retain.rs:151:5
88+
--> $DIR/use_retain.rs:169:5
7789
|
7890
LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect();
7991
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
8092

8193
error: this expression can be written more simply using `.retain()`
82-
--> $DIR/use_retain.rs:152:5
94+
--> $DIR/use_retain.rs:170:5
95+
|
96+
LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect();
97+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
98+
99+
error: this expression can be written more simply using `.retain()`
100+
--> $DIR/use_retain.rs:171:5
83101
|
84102
LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect();
85103
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
86104

87105
error: this expression can be written more simply using `.retain()`
88-
--> $DIR/use_retain.rs:172:5
106+
--> $DIR/use_retain.rs:193:5
89107
|
90108
LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect();
91109
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
92110

93111
error: this expression can be written more simply using `.retain()`
94-
--> $DIR/use_retain.rs:173:5
112+
--> $DIR/use_retain.rs:194:5
113+
|
114+
LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect();
115+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
116+
117+
error: this expression can be written more simply using `.retain()`
118+
--> $DIR/use_retain.rs:195:5
95119
|
96120
LL | vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect();
97121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
98122

99-
error: aborting due to 15 previous errors
123+
error: aborting due to 19 previous errors
100124

0 commit comments

Comments
 (0)