I have the following structure
struct SceneNode{
//...
mesh : Cell<Option<Rc<SceneMesh>>>,
}
Each SceneNode can have an optional reference to a SceneMesh. The SceneNode is part of a hierarchy and there can be many references to the same Node ( which is why I use Cell for the mesh. )
This works but it is quite clunky to use as I cant see a way to use mesh without first doing a take, then clone, then finally put it back in.
let local = scene_node.mesh.take(); // take the mesh from the cell. Cell is now empty
scene_node.mesh.set(local.clone()); // put the cloned copy back in.
//.. use local
The above works but it feels very, very wrong. Is there a cleaner, or a more succinct way of cloning a Cell<Option<Rc<Struct>>>>