Interior mutability help


#1

Hi,

For short the code is here. I want to be able to mutate simultaneously the nodes in the graph and any other field (for instance the ordering). This however I can not achieve if I have Vec<Expr> which is why I changed it to RefCell. However, now I get this compilation error, which I understand why I get it. However, I did not think of any approach to go around it, could anyone help with any suggestion.

Just to give a more detail essentially I need to be able to mutate different parts of the struct simultanously, however methods like the get above fails in this situation.


#2

Graph data structures are hard to do in safe Rust. Maybe this can help you: http://cglab.ca/~abeinges/blah/too-many-lists/book/


#3

I agree with ConnyOnny the link provided is a great example that helps to understand the problem better. I would also want to point you toward the following two posts:

and
http://smallcultfollowing.com/babysteps/blog/2015/04/06/modeling-graphs-in-rust-using-vector-indices/