Skip to content

Clarify how deref coercions interact with traits #3670

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

Closed
wants to merge 1 commit into from

Conversation

Spartan2909
Copy link

The book currently doesn't state that deref coercions don't always happen when matching traits, which has led to some confusion (see rust-lang/rust#109829). The nomicon does state this, but that is aimed at a different audience to the book.

Copy link
Contributor

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

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

I think this is valuable information, but I don’t think it makes sense to have it here. We don’t discuss fully-qualified syntax until Chapter 20, and for good reason: it’s a pretty advanced topic. I just reread that section, and unfortunately, I don’t think this fits there particularly well, either, though—mostly because it’s just one of those “this is an edge case that does matter but isn’t really part of ‘normal’/day-to-day Rust”. (I think I probably write a Trait::method() once for every hundred times I write it in the method format, if that!)

I agree this should be documented; you might file an issue on the Rust Reference and see if and how it makes sense to add to that, instead?

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.

None yet

2 participants