Conversation

something that intimidates me about learning a new language, is that I'm not experienced enough to make things simple
23
166
Replying to
I tried writing something fun in Rust, but it needed a graph data structure, and the Rust memory model doesn't believe in graphs or at least that's what a quick googling led me to believe
2
6
Replying to and
Most of the problem has to do with ownership of the reference to a graph node or edge. It's also why (doubly-)linked lists are hard. I imagine some tricks could be played with RefCell<T>, Rc<T>, and Weak<T>, or some composition thereof, to get somewhere fruitful.
1
4
Rc<T> and Weak<T> works for a graph with a clear tree-like ownership structure. The ownership structure still needs to be a tree or you'll leak memory. If you have cycles, those are going to leak unless you do something about it and in that case using Rc<T> doesn't seem useful.
1
3