3 ms·
It's more complex than it needs to be; there's no reason to put a Box there, for example. (Even though the blog post is from April, it links to a SO question fr
by steveklabnik 9y ago
It's more complex than it needs to be; there's no reason to put a Box there, for example. (Even though the blog post is from April, it links to a SO question from 2015, where that Box was necessary, but as of Rust 1.4, a few months later, it is not. This info is in the comments of that answer.)
It's also very unclear why they created an entire second Rc rather than just cloning the first one, as that's the point of Rc.
Compare:
fn my_trait_fn(t: &MyTrait) {
t.trait_func();
}
fn main() {
let my_str = Rc::new(RefCell::new(MyStruct1));
my_trait_fn(&*my_str.borrow());
my_str.borrow().my_fn();
}