Hello everyone !
I saw on the rust doc that cells are shareable mutable containers. I though RefCells were just like cells but for objects without the Copy trait, it gives you references. Now, how to I share the RefCell then ? Calling .clone() like I would on an Rc seems to clone the content of the cell if it implements the Clone trait, or give me an error if it doesn't. What should I do ? I'm sure there's an easy way to solve this.
Ok, so that's how it's supposed to work. Though RefCells were shareable like Rcs or Cells. Thanks !
Cell isn't shareable either. Sharing and shared mutability are separate concerns, so they are separate types in Rust.
Rc handles sharing and
RefCell is for shared mutability.
RefCell<T> directly contains the
T. It is not a (smart) pointer type.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.