How do I pass Rc to a function accepting Rc?

(An older revision of this answer essentially advised to clone the underlying struct and put it in a new Rc<RefCell<Box<MyTrait>> object; this was necessary at the time on stable Rust, but since not long after that time, Rc<RefCell<MyStruct>> will coerce to Rc<RefCell<MyTrait>> without trouble.) Drop the Box<> wrapping, and you can coerce Rc<RefCell<MyStruct>> to Rc<RefCell<MyTrait>> … Read more

Understanding Traits and Object Safety

Why does this particular example not work? The chapter Trait Objects states: So what makes a method object-safe? Each method must require that Self: Sized Isn’t that fulfilled? This question really is: What is a trait object? A trait object is an interface in the Object-Oriented paradigm: it exposes a limited set of methods, which … Read more