4 ms·
I thought you could do this: Animal::talk(self);
by jdub 11y ago
I thought you could do this:
Animal::talk(self);
- chrismorgan 11y agoThere is no such thing as `Animal::talk`. It does not exist. `Animal::talk` is purely shorthand for `<_ as Animal>::talk`, meaning that it is a specific type’s implementation of the `talk` method. In the case of `Animal::talk(dog)` where `dog` is of type `&Dog`, the `_` can be inferred to be `Dog`, and so `Animal::talk(dog)` is equivalent to `Dog::talk(dog)` and `<Dog as Animal>::talk(dog)`. The default implementation, if overridden, does not exist for the given type.
- deleted 11y ago[deleted]