-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conventions for the use of Deref
and DerefMut
#279
Comments
I am keen to see some guidance here. In particular, I find deref'ing to an unrelated type for the sake of convenience a confusing anti-pattern. My preference would be for deref to only be used for getting the contents of a smart pointer and for taking a slice of a collection, but I'm sure there are other similar cases I haven't thought of. However, using deref for polymorphism using method calls seems pretty bad. cc @aturon |
What is 'unrelated'? |
@nick29581 Yes, I am also anxious to establish some guidelines here; it's coming up increasingly often in |
Also |
Derefing an |
I wondered if that Deref impl got removed, but no, it's still there: https://github.com/rust-lang/rust/blob/02f5786a324c40b2d8b2d0df98456e48fb45d30c/src/librustc_resolve/check_unused.rs |
This was discussed previously in rust-lang/rust#13126.
Tracking issue for postponed PR #25
The text was updated successfully, but these errors were encountered: