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

Change to_owned to to_string in docs #39024

Merged
merged 1 commit into from Jan 14, 2017
Merged

Change to_owned to to_string in docs #39024

merged 1 commit into from Jan 14, 2017

Conversation

ghost
Copy link

@ghost ghost commented Jan 13, 2017

We should teach conversion from str to String using to_string rather than the legacy to_owned.

We should teach conversion from `str` to `String` using `to_string`
rather than the legacy `to_owned`.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@ghost
Copy link
Author

ghost commented Jan 13, 2017

By the way, there are around 150 uses of type "something".to_owned() in the actual source (not documentation). Would it make sense to update them now, too?

@steveklabnik
Copy link
Member

@bors: r+ rollup

Thanks!

Last I checked, @rust-lang/compiler wasn't sold on doing that automatically, maybe their opinion has changed.

@bors
Copy link
Contributor

bors commented Jan 13, 2017

📌 Commit d5c3bec has been approved by steveklabnik

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jan 13, 2017
…abnik

Change `to_owned` to `to_string` in docs

We should teach conversion from `str` to `String` using `to_string` rather than the legacy `to_owned`.
bors added a commit that referenced this pull request Jan 13, 2017
Rollup of 10 pull requests

- Successful merges: #38362, #38636, #38877, #38946, #38965, #38986, #38994, #38995, #39024, #39027
- Failed merges:
@bors bors merged commit d5c3bec into rust-lang:master Jan 14, 2017
@ghost ghost deleted the owned-to-string branch January 14, 2017 08:50
@nrc
Copy link
Member

nrc commented Jan 16, 2017

:-( I prefer to_owned rather than to_string - I think it describes most clearly the transform that is happening (converting a borrowed string to an owned string) and is most likely to let you know when you are doing something unexpected (since to_string will convert a whole bunch of stuff to a string, you could think you are converting an &str but are actually converting something else, thus hiding an underlying issue).

@ghost
Copy link
Author

ghost commented Jan 16, 2017

@nrc I see your point, but after we got specialization to_string became more-or-less the idiomatic way, and consistency in documentation is important.

I would personally like it best if &'static str would be automatically coerced to String. Both "smth".to_owned() and "smth".to_string() look pretty bad to me. Eh, it's hard to make everyone happy :)

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.

5 participants