4 ms·
You can define a field with the type of the base class in the subclass, and impl Deref for SubClass, with Target = BaseClass.
by glandium 4y ago
You can define a field with the type of the base class in the subclass, and impl Deref for SubClass, with Target = BaseClass.
- cylon13 4y agoYou can, but the docs for Deref beg you not to use Deref for types that aren’t smart pointers because of how confusing and surprising the results can be to an unfamiliar reader of the code.