I've recently done something like the following a couple times... wondering if it's a common pattern or there's another approach?
//create 2 copies of foo because one gets owned by the closure
//and the other is owned outside the closure
//also needs interior mutability
let foo1 = Rc::new(RefCell::new(Foo{...}));
let foo2 = Rc::clone(&foo1);
//move is required for reasons (e.g. interfacing with JS where it'll be `static)
do_something(move || {
//do something with foo1
foo1....
});
//this could happen at an artbitrary time
*foo2.borrow_mut() = Foo{...}