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

std::convert docs mention the "to" convention, but don't implement it #24712

Closed
shepmaster opened this issue Apr 23, 2015 · 3 comments · Fixed by #24772
Closed

std::convert docs mention the "to" convention, but don't implement it #24712

shepmaster opened this issue Apr 23, 2015 · 3 comments · Fixed by #24772

Comments

@shepmaster
Copy link
Member

The std::convert docs say:

They follow the standard Rust conventions of as/to/into/from.

(emphasis mine)

However, there isn't a To trait, and none of AsMut / AsRef / From / Into implement a to method. Not sure if this is a typo or an oversight resulting in a missing trait.

@steveklabnik
Copy link
Member

Typo, I think. /cc @aturon

@shepmaster
Copy link
Member Author

I'd guess that Into<Foo> for &Bar is really the equivalent of the old Bar::to_foo(&self), while Into<Foo> for Bar is the equivalent of Bar::into_foo(self). If correct, maybe that's what can be added somewhere.

@aturon
Copy link
Member

aturon commented Apr 24, 2015

Yes, this comment was left in from the initial implementation, which included To.

What we found eventually was that bounding by To doesn't make a lot of sense; as @shepmaster points out, Into can cover both the to and into-style conversions, and using Into instead gives the caller more flexibility (since they can pass in an owned object of the target type, or one that requires conversion).

steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 24, 2015
mdinger pushed a commit to mdinger/rust that referenced this issue Apr 24, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 24, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 24, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 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 a pull request may close this issue.

3 participants