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
When I initially contributed Rc<T> to Rust, it statically prevented cycles. The type constraints needed made it a lot less useful. You can create cycles now, but it's essentially broken and you aren't really supposed to do it. Connections forming a cycle are meant to be Weak<T>.
4