A convenient wrapper for Rc<RefCell<T>>>
and Weak<RefCell<T>>>
.
The RcCell
library adds two new structs:
- RcCell<T>
: a wrapper for Rc<RefCell<T>>
.
- WeakCell<T>
: a wrapper for Weak<RefCell<T>>
.
This library extends the rc-cell
library.
```rust use rccell::{RcCell, WeakCell};
let a = RcCell::new(1); // a is a RcCell that wraps an Rc
let mut c = a.borrowmut(); // You can use borrow and borrowmut methods as if RcCells were RefCells *c = 2; // let mut d = b.borrow_mut() You cannot create two RefMuts for the same RcCell. drop(c);
assert!(a.tryborrow().isok()); // You can use tryborrow and tryborrowmut to avoid panicking // let d = a.unwrap() You can use unwrap to get the inner value (if there is only one RcCell) assert!(a.tryunwrap().iserr()); // You can use tryunwrap to avoid panicking
let d: WeakCell