Commit Graph

418 Commits

Author SHA1 Message Date
Domantas Jadenkus
f098a2b31b move into_ and as_ generation to a separate file 2021-02-27 12:21:06 +02:00
Domantas Jadenkus
6f25fef36a cargo fmt 2021-02-27 12:06:00 +02:00
Domantas Jadenkus
e0f08fcc20 add generate_enum_as_method assist 2021-02-27 12:06:00 +02:00
Domantas Jadenkus
642786986f deduplicate some 2021-02-27 12:05:59 +02:00
Domantas Jadenkus
2dcd5d7a7c add generate_enum_into_method assist 2021-02-27 12:05:59 +02:00
Domantas Jadenkus
4ab285a8e5 make generate_enum_is_method work on any variants 2021-02-27 12:05:59 +02:00
Domantas Jadenkus
f67586066d rename existing assist to generate_enum_is_method 2021-02-27 12:05:59 +02:00
Denys Zadorozhnyi
eb3c23588d
Disable "Flip comma" assist inside a macro call 2021-02-26 19:12:53 +02:00
Sanchith Hegde
3eaec3cd33
docs(ide_assists): Change importMergeBehaviour to importMergeBehavior 2021-02-26 12:54:50 +05:30
John Renner
9eecba4dbf Implement line<->block comment assist 2021-02-24 17:13:00 -08:00
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
Matt Hall
a28e862825 Address further review comments
* Use known names for iter/iter_mut method (simplifies checking if the
  method exists
* Extract code to check assist with fixtures to function
2021-02-24 19:23:12 +00:00
Lukas Wirth
694f7a7e9f Add tests for apply_demorgan 2021-02-24 11:58:37 +01:00
lbrande
9db970ee08 De Morgan's Law assist now correctly inverts <, <=, >, >=. 2021-02-24 11:58:37 +01:00
lbrande
f7a4a87de2 De Morgan's Law assist now correctly parenthesizes binary expressions. 2021-02-24 11:58:37 +01:00
Matt Hall
98a626450d Address review comments
* Move code to build replacement into closure
* Look for iter/iter_mut methods on types behind reference
2021-02-23 19:19:48 +00:00
Matt Hall
506293ca43 Add convert_for_to_iter_for_each assist 2021-02-23 18:10:01 +00:00
Chetan Khilosiya
e4756cb4f6 7526: Rename crate assists to ide_assists. 2021-02-23 00:59:16 +05:30