Skip to content

feat(assists): Make raw string unescaped #1922

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

Merged
merged 5 commits into from
Oct 8, 2019

Conversation

Geobert
Copy link
Contributor

@Geobert Geobert commented Sep 26, 2019

Last piece of #1730

@matklad
Copy link
Member

matklad commented Sep 28, 2019

I think it's better to only have two assists

  1. usual string -> raw string
  2. raw string -> usual string

In general, adding many assists is bad, because it makes it harder to find the correct one among the noise.

The assists should be semantic preserving. This is not entirely true at the moment: make raw string of "hello\nworld"; gives r"hello\nworld";, while it should be

r#"hello
world"#;

(not also a hash: I thin it's a good idea to add one hash by default, as, if you don't need hashes, it's easy to just add r yourself)

@Geobert
Copy link
Contributor Author

Geobert commented Sep 28, 2019

So we're discarding the proposal from @bjorn3? (fine by me, just to be sure) I can add the hash by default.

Do we keep "add hash" and "remove hash" assists?

@matklad
Copy link
Member

matklad commented Sep 28, 2019

So we're discarding the proposal from bjorn3?

Yeah, I feel like having two flavors of the thing would be more confusing than helpful.

Do we keep "add hash" and "remove hash" assists?

Yep, as they are only available if there's already a string literal.

Add max_hashes_streak + 1 hashes to the raw string
Count `"#*` streak only, extract the counting in a function, unit test this function
@matklad
Copy link
Member

matklad commented Oct 8, 2019

bors r+

Thanks!

bors bot added a commit that referenced this pull request Oct 8, 2019
1922: feat(assists): Make raw string unescaped r=matklad a=Geobert

Last piece of #1730

Co-authored-by: Geobert Quach <[email protected]>
@bors
Copy link
Contributor

bors bot commented Oct 8, 2019

Build succeeded

@bors bors bot merged commit 31663c1 into rust-lang:master Oct 8, 2019
@Geobert Geobert deleted the raw-string-unescape branch October 10, 2019 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants