-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Clarify docs on implementing Into. #42126
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
This works when I tried it. https://play.rust-lang.org/?gist=29711851d1acb274cd4ba9fd3e05d781 struct Wrapper(String);
impl From<Wrapper> for String {
fn from(w: Wrapper) -> String {
w.0
}
}
fn main() {} |
Travis failed:
|
src/libcore/convert.rs
Outdated
/// not part of the current crate, then you can't implement `From` directly. | ||
/// For example, take this crate: | ||
/// | ||
/// ```{.compile_fail} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the {}
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compile_fail code block actually compiles fine.
@clarcharr a gentle reminder that this PR is awaiting your deft hand to fix the failures and respond to review feedback. |
@shepmaster my deft hand has responded. |
Looks like this still needs a few more updates to get Travis passing.
|
My deft hand failed me once again :( (fixed the error) |
src/libcore/convert.rs
Outdated
/// generic variable, then you can't implement `From` directly. For example, | ||
/// take this crate: | ||
/// | ||
/// ```.compile_fail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the .
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Rebased and made the changes. |
@bors: r+ rollup thanks! |
📌 Commit 54bbe23 has been approved by |
Clarify docs on implementing Into. This was suggested by @dtolnay in rust-lang#40380. This explicitly clarifies in what circumstances you should implement `Into` instead of `From`.
This was suggested by @dtolnay in #40380.
This explicitly clarifies in what circumstances you should implement
Into
instead ofFrom
.