Skip to content

book: explanation that String -> &str coercion doesn't happen for &str traits #25742

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 2 commits into from
May 25, 2015

Conversation

thombles
Copy link
Contributor

A few of us over on the forum have been tripped up by this distinction, which I don't think is mentioned. It's kind of logical if you read the "Deref coercions" page and squint a bit but I think it would be nice to explain it directly. Here's one way we could clarify it.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (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. 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 CONTRIBUTING.md for more information.

of type `ToSocketAddrs`. A `&str` is okay but a `String` must be explicitly
converted using `&*`.

```rust
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be tagged no_run as well, because it won't work, since there's no server, yeah?

@steveklabnik
Copy link
Member

Thanks so much! r=me after the nit

@thombles
Copy link
Contributor Author

I've added no_run and a use statement so it will build. Not a bad thing to have anyway. check-docs is all good now.

@steveklabnik
Copy link
Member

@bors: r+ rollup

@bors
Copy link
Collaborator

bors commented May 25, 2015

📌 Commit 2b3354c has been approved by steveklabnik

@steveklabnik
Copy link
Member

Thanks so much!

bors added a commit that referenced this pull request May 25, 2015
A few of us [over on the forum](https://users.rust-lang.org/t/string-type-coercion-in-rust/1439) have been tripped up by this distinction, which I don't think is mentioned. It's kind of logical if you read the "Deref coercions" page and squint a bit but I think it would be nice to explain it directly. Here's one way we could clarify it.
@bors
Copy link
Collaborator

bors commented May 25, 2015

⌛ Testing commit 2b3354c with merge 6770253...

@bors bors merged commit 2b3354c into rust-lang:master May 25, 2015
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.

4 participants