3 ms·
It looks like they're different kinds of difficult. From your link: « In hindsight and with a deeper understanding, it’s not surprising why a doubly linked lis
by phyzome 8y ago
It looks like they're different kinds of difficult. From your link:
« In hindsight and with a deeper understanding, it’s not surprising why a doubly linked list is so problematic. Each variable can only have 1 owner. If prev and next both hold pointers to a middle node, which is the owner? They can’t both be the owner. If one is the owner, another can borrow. But Rust won’t let you mutate while someone else is borrowing, so neither could actually modify the list! In general, if you have loops in your object graph you’re out of luck. »
So the solution for doubly linked lists is to write some "unsafe"-marked Rust once, really bang on it, and ship that in a crate full of generic data structures. This is acceptable to me; it's no worse than C.
With closures, it sounds like the issue is not that it's impossible, but that the lifetime and mutability analysis get tricky in some cases.