diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-17 09:30:08 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-17 09:30:08 +0100 |
commit | b5830fbf9222b9a83309dc61fe1df480b0c3b153 (patch) | |
tree | b927b06a3f866f6ebac907d7714fa05af7422d4e /crates/ide_assists/src | |
parent | 7b4f5c0262bbdf7e9db81734eb9c82dd04eb82cb (diff) | |
parent | c42cdff3d2ed2e30add09dd0d602181b6f83534d (diff) |
Merge #9306
9306: internal: minimize minicore r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ide_assists/src')
-rw-r--r-- | crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs | 78 |
1 files changed, 25 insertions, 53 deletions
diff --git a/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs index 8e571723d..5f2aa016f 100644 --- a/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs +++ b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs | |||
@@ -186,18 +186,14 @@ fn main() { | |||
186 | fn test_for_borrowed() { | 186 | fn test_for_borrowed() { |
187 | check_assist( | 187 | check_assist( |
188 | replace_for_loop_with_for_each, | 188 | replace_for_loop_with_for_each, |
189 | r" | 189 | r#" |
190 | //- minicore: iterator | 190 | //- minicore: iterators |
191 | struct Iter; | 191 | use core::iter::{Repeat, repeat}; |
192 | impl Iterator for Iter { | ||
193 | type Item = usize; | ||
194 | fn next(&mut self) -> Option<Self::Item> { None } | ||
195 | } | ||
196 | 192 | ||
197 | struct S; | 193 | struct S; |
198 | impl S { | 194 | impl S { |
199 | fn iter(&self) -> Iter { Iter } | 195 | fn iter(&self) -> Repeat<i32> { repeat(92) } |
200 | fn iter_mut(&mut self) -> Iter { Iter } | 196 | fn iter_mut(&mut self) -> Repeat<i32> { repeat(92) } |
201 | } | 197 | } |
202 | 198 | ||
203 | fn main() { | 199 | fn main() { |
@@ -206,18 +202,14 @@ fn main() { | |||
206 | let a = v * 2; | 202 | let a = v * 2; |
207 | } | 203 | } |
208 | } | 204 | } |
209 | ", | 205 | "#, |
210 | r" | 206 | r#" |
211 | struct Iter; | 207 | use core::iter::{Repeat, repeat}; |
212 | impl Iterator for Iter { | ||
213 | type Item = usize; | ||
214 | fn next(&mut self) -> Option<Self::Item> { None } | ||
215 | } | ||
216 | 208 | ||
217 | struct S; | 209 | struct S; |
218 | impl S { | 210 | impl S { |
219 | fn iter(&self) -> Iter { Iter } | 211 | fn iter(&self) -> Repeat<i32> { repeat(92) } |
220 | fn iter_mut(&mut self) -> Iter { Iter } | 212 | fn iter_mut(&mut self) -> Repeat<i32> { repeat(92) } |
221 | } | 213 | } |
222 | 214 | ||
223 | fn main() { | 215 | fn main() { |
@@ -226,7 +218,7 @@ fn main() { | |||
226 | let a = v * 2; | 218 | let a = v * 2; |
227 | }); | 219 | }); |
228 | } | 220 | } |
229 | ", | 221 | "#, |
230 | ) | 222 | ) |
231 | } | 223 | } |
232 | 224 | ||
@@ -259,18 +251,14 @@ fn main() { | |||
259 | fn test_for_borrowed_mut() { | 251 | fn test_for_borrowed_mut() { |
260 | check_assist( | 252 | check_assist( |
261 | replace_for_loop_with_for_each, | 253 | replace_for_loop_with_for_each, |
262 | r" | 254 | r#" |
263 | //- minicore: iterator | 255 | //- minicore: iterators |
264 | struct Iter; | 256 | use core::iter::{Repeat, repeat}; |
265 | impl Iterator for Iter { | ||
266 | type Item = usize; | ||
267 | fn next(&mut self) -> Option<Self::Item> { None } | ||
268 | } | ||
269 | 257 | ||
270 | struct S; | 258 | struct S; |
271 | impl S { | 259 | impl S { |
272 | fn iter(&self) -> Iter { Iter } | 260 | fn iter(&self) -> Repeat<i32> { repeat(92) } |
273 | fn iter_mut(&mut self) -> Iter { Iter } | 261 | fn iter_mut(&mut self) -> Repeat<i32> { repeat(92) } |
274 | } | 262 | } |
275 | 263 | ||
276 | fn main() { | 264 | fn main() { |
@@ -279,18 +267,14 @@ fn main() { | |||
279 | let a = v * 2; | 267 | let a = v * 2; |
280 | } | 268 | } |
281 | } | 269 | } |
282 | ", | 270 | "#, |
283 | r" | 271 | r#" |
284 | struct Iter; | 272 | use core::iter::{Repeat, repeat}; |
285 | impl Iterator for Iter { | ||
286 | type Item = usize; | ||
287 | fn next(&mut self) -> Option<Self::Item> { None } | ||
288 | } | ||
289 | 273 | ||
290 | struct S; | 274 | struct S; |
291 | impl S { | 275 | impl S { |
292 | fn iter(&self) -> Iter { Iter } | 276 | fn iter(&self) -> Repeat<i32> { repeat(92) } |
293 | fn iter_mut(&mut self) -> Iter { Iter } | 277 | fn iter_mut(&mut self) -> Repeat<i32> { repeat(92) } |
294 | } | 278 | } |
295 | 279 | ||
296 | fn main() { | 280 | fn main() { |
@@ -299,7 +283,7 @@ fn main() { | |||
299 | let a = v * 2; | 283 | let a = v * 2; |
300 | }); | 284 | }); |
301 | } | 285 | } |
302 | ", | 286 | "#, |
303 | ) | 287 | ) |
304 | } | 288 | } |
305 | 289 | ||
@@ -332,28 +316,16 @@ fn main() { | |||
332 | check_assist( | 316 | check_assist( |
333 | replace_for_loop_with_for_each, | 317 | replace_for_loop_with_for_each, |
334 | r#" | 318 | r#" |
335 | //- minicore: iterator | 319 | //- minicore: iterators |
336 | struct Iter; | ||
337 | impl Iterator for Iter { | ||
338 | type Item = usize; | ||
339 | fn next(&mut self) -> Option<Self::Item> { None } | ||
340 | } | ||
341 | |||
342 | fn main() { | 320 | fn main() { |
343 | for$0 a in Iter.take(1) { | 321 | for$0 a in core::iter::repeat(92).take(1) { |
344 | println!("{}", a); | 322 | println!("{}", a); |
345 | } | 323 | } |
346 | } | 324 | } |
347 | "#, | 325 | "#, |
348 | r#" | 326 | r#" |
349 | struct Iter; | ||
350 | impl Iterator for Iter { | ||
351 | type Item = usize; | ||
352 | fn next(&mut self) -> Option<Self::Item> { None } | ||
353 | } | ||
354 | |||
355 | fn main() { | 327 | fn main() { |
356 | Iter.take(1).for_each(|a| { | 328 | core::iter::repeat(92).take(1).for_each(|a| { |
357 | println!("{}", a); | 329 | println!("{}", a); |
358 | }); | 330 | }); |
359 | } | 331 | } |