News for hackers. Stuff that matters.
Re:How I went about learning Rust by glandium on Friday July 15, 2022 @05:52AM (#32106446)
You can define a field with the type of the base class in the subclass, and impl Deref for SubClass, with Target = BaseClass.
Re:How I went about learning Rust by cylon13 on Friday July 15, 2022 @12:30PM (#32109874)
You 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.