4 ms·
What do you mean you can't return self? I'm just starting out with learning rust, but from what I've gathered you can use objects in a myriad of ways that will
by cbcoutinho 9y ago
What do you mean you can't return self? I'm just starting out with learning rust, but from what I've gathered you can use objects in a myriad of ways that will allow you do what you need.
Instead of returning self, you could just pass a reference - you need to mutate self then just pass a mutable reference. Did I miss something here?
- steveklabnik 9y agoReturning Self in a trait object isn't possible; it's not object safe. In order to return Self, you'd need to know the concrete type of the thing, and when you have a trait object, that's erased. Returning a trait object instead of plain Self would work though.