Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upBug in rust automatic deref for methods of generic traits #48145
Comments
pietroalbini
added
C-enhancement
T-compiler
labels
Feb 11, 2018
This comment has been minimized.
This comment has been minimized.
|
You can use the fully qualified syntax, and it will work:
Agree that it is not completely ergonomic. |
This comment has been minimized.
This comment has been minimized.
|
Sounds like an Basically, you've created a situation where it is not possible to express all of the possible signatures of I suspect that the actual specialization feature faces problems like this as well. Edit: struck out "unavoidable" because I don't know that. |
porky11 commentedFeb 11, 2018
Normally generics should just work like specialized versions, just substituted with the correct type.
For example
trait MyTrait<T> {…}is intended to work for a type MyType as if I definedtrait MyTrait_MyType {…}.This doesn't apply, when one specialized version of a generic trait is implemented for a type T, which derefs to U, which implements a different specialization of the same trait.
Then the specialized version for T also shadows the specialized version for U, even if they could both be called on this type.
I made an example to show, what this means here.