Arc<RefCell>
or Arc<Cell<T>>
RS-W1056Arc
may be used with Sync
types to share them safely across thread
boundaries, however, RefCell
and Cell
aren't Sync
, making Arc<RefCell<T>>
and Arc<Cell<T>>
useless types.
If you want to share T
between threads, then consider
using Arc<Mutex<T>>
or a primitive from the std::sync
.
struct Foo {
shared_data: Arc<RefCell<T>>,
}
struct Foo {
shared_data: Arc<Mutex<T>>,
}