I want to share a structure Foo
between several other structures
with the ability to extract this data. All other holders of this structure will see the value disappear.
Pseudocode:
if boo.ref_to_foo.is_valid() {
let foo: Foo = boo.ref_to_foo.steal(); //1
} else {
//after executing 1 one time all come here
}
I do not need multithreading.
Is Rc<RefCell<Foo>>
what I want? Deref for Rc
+ RefCell::borrow_mut
+ Option::take
, or maybe some simpler way to achieve what I want?