Hello,
I am stuck at understanding the method implementation for generic types:
By declaring
T
as a generic type afterimpl
, Rust can identify that the type in the angle brackets inPoint
is a generic type rather than a concrete type. We could have chosen a different name for this generic parameter than the generic parameter declared in the struct definition, but using the same name is conventional.
Does the above mean to imply that we could have something like the following:
impl<T> GenericStruct<U>
I understand from trying it out that this does not work since the compiler tries to lookup type U
. So what is "We could have chosen a different name for this generic parameter than the generic parameter declared in the struct definition, but using the same name is conventional" trying to say? Could someone please explain?