rust/crates
bors[bot] dc14c432f5
Merge #7741
7741: Add convert_for_to_iter_for_each assist r=mattyhall a=mattyhall

Implements one direction of #7681 

I wonder if this tries to guess too much at the right thing here. A common pattern is:

```rust
let col = vec![1, 2, 3];
for v in &mut col {
  *v *= 2;
}
// equivalent to:
col.iter_mut().for_each(|v| *v *= 2);
```

I've tried to detect this case by checking if the expression after the `in` is a (mutable) reference and if not inserting iter()/iter_mut(). This is just a convention used in the stdlib however, so could sometimes be wrong. I'd be happy to make an improvement for this, but not sure what would be best. A few options spring to mind:
1. Only allow this for types that are known to have iter/iter_mut (ie stdlib types)
2. Try to check if iter/iter_mut exists and they return the right iterator type
3. Don't try to do this and just add `.into_iter()` to whatever is after `in`

Co-authored-by: Matt Hall <matthew@quickbeam.me.uk>
2021-02-24 19:24:22 +00:00
..
base_db Make more common assist easier to ues 2021-02-22 16:07:08 +03:00
cfg
flycheck
hir Don't write trailing whitespace when formatting empty GenericPredicates 2021-02-20 20:43:04 +01:00
hir_def is_visible_from_def_map: handle block expressions 2021-02-23 17:56:16 +01:00
hir_expand Address further review comments 2021-02-24 19:23:12 +00:00
hir_ty Add test from #7273 2021-02-21 19:22:14 +02:00
ide Pickup ConstReference patterns in FindUsages 2021-02-23 23:31:53 +01:00
ide_assists Merge #7741 2021-02-24 19:24:22 +00:00
ide_completion Add test 2021-02-23 14:54:01 +01:00
ide_db De Morgan's Law assist now correctly inverts <, <=, >, >=. 2021-02-24 11:58:37 +01:00
ide_ssr 7526: Renamed create ssr to ide_ssr. 2021-02-23 00:59:16 +05:30
mbe
parser Specialization for async traits 2021-02-15 18:33:12 +01:00
paths
proc_macro_api Remove redundant clones 2021-02-05 16:57:26 +01:00
proc_macro_srv Add isize to the list of suffixed integers in typed_integer 2021-02-22 14:48:56 +01:00
proc_macro_test
profile
project_model Fix a few clippy::perf warnings 2021-02-16 10:55:34 -05:00
rust-analyzer 7526: Renamed create ssr to ide_ssr. 2021-02-23 00:59:16 +05:30
stdx Cleanup decl_check 2021-02-05 16:09:45 +01:00
syntax Add tests for apply_demorgan 2021-02-24 11:58:37 +01:00
test_utils Add parsing benchmark 2021-02-09 21:52:34 +03:00
text_edit
toolchain
tt
vfs Fix slow tests sometimes failing 2021-02-12 16:31:16 +01:00
vfs-notify Fix slow tests sometimes failing 2021-02-12 16:31:16 +01:00