The problem is that, as stated in the error message, the TraitToImpl
property TraitToImpl
not safe for the object. That is, it is not safe to use this particular attribute by reference (i.e. &TraitToImpl
or Box<TraitToImpl>
.
In particular, the do_something
method takes the value self
by value. Consider: how Box<TraitToImpl>
compiler call this method on a Cont
that was placed in a Box<TraitToImpl>
? It should copy the value into an argument of type Cont
(this is what impl
expects), but this call should work for any type of any size that TraitToImpl
can implement!
Bottom line: if you have a trait containing the value self
or generics, it cannot be used with a link. The moment the call comes in, the compiler no longer has enough information to actually generate the necessary code.
Maybe instead we take &self
? :)
source share