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

Add str_ref_to_string fix #12696

Merged
merged 2 commits into from
Jul 13, 2022
Merged

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Jul 5, 2022

close #11383
When type mismatch is &str -> String try to fix it.

@Rustin170506

This comment was marked as outdated.

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@Rustin170506 Rustin170506 marked this pull request as ready for review July 9, 2022 03:40
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@Rustin170506
Copy link
Member Author

@Veykril
Could you please take a look? Thanks! 💚 💙 💜 💛 ❤️

@Veykril
Copy link
Member

Veykril commented Jul 11, 2022

I'm a bit busy atm, will take a look when I find the time (unless someone beats me to it)

@Veykril
Copy link
Member

Veykril commented Jul 13, 2022

We probably want this to be a bit more generally applicable if possible (and certainly not just text based by checking the types names) but in this instance this seems fine for now I think. We can figure out the better way afterwards since this is self-contained.

Thanks
@bors r+

@bors
Copy link
Contributor

bors commented Jul 13, 2022

📌 Commit 638abba has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 13, 2022

⌛ Testing commit 638abba with merge fc47ce5...

@bors
Copy link
Contributor

bors commented Jul 13, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing fc47ce5 to master...

@bors bors merged commit fc47ce5 into rust-lang:master Jul 13, 2022
@Rustin170506 Rustin170506 deleted the rustin-patch-fix branch July 13, 2022 13:51
@lnicola
Copy link
Member

lnicola commented Jul 18, 2022

add-to-string.mp4

@rben01
Copy link

rben01 commented Jul 18, 2022

I feel like to_owned and into would be better options than to_string here. to_string means, essentially, "convert to the String that Display::fmt would give me". For &str, this happens to be the same as converting to an owned String, but that seems like a happy coincidence. to_owned and into are more explicit about the nature of the transformation taking place.

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.

IDE Assist for &str -> String
5 participants