A bad way to do that is simply transmute &Rc<dyn Trait>
to &Rc<T>
. This works because &Rc<dyn Trait>
should be represented as &(Rc<()>, &VTable)
, so we could reinterpret-cast the reference to only refer to its header &Rc<()>
. This is similar to C-style cast to base-class.
1 Like