Rust

Rust

Made by DeepSource

Found occurrence of Arc<RefCell> or Arc<Cell<T>> RS-W1056

Anti-pattern
Minor

Arc 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.

Bad practice

struct Foo {
    shared_data: Arc<RefCell<T>>,
}

Recommended

struct Foo {
    shared_data: Arc<Mutex<T>>,
}