3 ms·
A heap would be simple. Rust's ownership rules make it hard to implement data structures composed of nodes that own references to other nodes. (This includes l
by tetromino_ 8y ago
A heap would be simple.
Rust's ownership rules make it hard to implement data structures composed of nodes that own references to other nodes. (This includes linked lists, binary trees, and naive implementations of graphs.) There is a reason for this - it's rather tricky to implement such data structures truly safely in any language without introducing hidden assumptions, that's why they are so frequently seen in interview questions for java and c++ coders.
- SilasX 8y agoThe difficulty of such interview questions doesn't stem from the problem of ensuring memory safety, but stuff like "finding the form of the recursion you need".