2 ms·
Aside from what other people have pointed out about these being possible in safe Rust (just with a cost -- a cost you pay in the other languages anyway); this i
by Manishearth 10y ago
Aside from what other people have pointed out about these being possible in safe Rust (just with a cost -- a cost you pay in the other languages anyway); this is not a useful yardstick for the amount of unsafe code you need to write.
These data structures are write once. You write them once, verify them, and use them as much as you want. The doubly linked list is in the stdlib. A tree without parent pointers is possible with zero cost in safe rust. A tree with parent pointers IIRC exists in a crate somewhere. So you will rarely be implementing these, just using these with safe code.
While we use datastructures to teach the "basics" of languages like C and C++, that doesn't mean that they are basic and any language where they are hard is crap. Rust makes them hard so that the rest of your code is easy to write. And since these are write-once, they have a minimal to zero impact on the amount of unsafe code in your codebase.