Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Extract arbitrary exprs in format string into named. #13180

Closed
crlf0710 opened this issue Sep 3, 2022 · 1 comment · Fixed by #13216
Closed

Feature request: Extract arbitrary exprs in format string into named. #13180

crlf0710 opened this issue Sep 3, 2022 · 1 comment · Fixed by #13216
Labels
A-assists C-feature Category: feature request

Comments

@crlf0710
Copy link
Member

crlf0710 commented Sep 3, 2022

println!("{obj.len()}"); is not supported by Rust language, but it would be nice if rust-analyzer could just convert it into
println!("{obj_len}", obj_len = obj.len());.

@Veykril Veykril added A-assists C-feature Category: feature request labels Sep 3, 2022
@kartva
Copy link
Contributor

kartva commented Sep 3, 2022

Hmm, I'd be interested in tackling this.

bors added a commit that referenced this issue Sep 12, 2022
…esmondWillowbrook

New assist: move_format_string_arg

The name might need some improving.

```rust
fn main() {
    print!("{x + 1}");
}
```
to
```rust
fn main() {
    print!("{}"$0, x + 1);
}
```

fixes #13180

ref to #5988 for similar work

* extracted `format_like`'s parser to it's own module in `ide-db`
* reworked the parser's API to be more direct
* added assist to extract expressions in format args
@bors bors closed this as completed in f64c956 Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists C-feature Category: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants