3 ms·
I wish they had a chapter covering how to efficiently implement graph algorithms without ending up in a struggle with the borrow checker.
by amelius 10y ago
I wish they had a chapter covering how to efficiently implement graph algorithms without ending up in a struggle with the borrow checker.
- wscott 10y agoHave you read this one yet? http://cglab.ca/~abeinges/blah/too-many-lists/book/ http://cglab.ca/~abeinges/blah/too-many-lists/book/ It touches on the issues you are implying.
- bennofs 10y agoA possibility is to use a different representation for graphs, such as adjacency matrices, which are much easier to work with the borrow checker. Or just use RefCell, deferring the borrow checking until runtime. Another strategy could be to give every node an explicit ID, and then have a mapping ID -> node. Every else you just refer to the nodes by their IDs.