|
|
|
|
|
by ok123456
1299 days ago
|
|
The ownership rules make it very difficult to write data structures. Even the most trivial singly linked lists have caused innumerable blog articles to be penned on how exactly to do that in the most idiomatic Rusty way. Personally, I don't see any problem with using unsafe Rust in these instances, because linear types are not appropriate model as you don't have a single source and sink. |
|
Uh, a singly linked list is trivial to implement...
Any data structure where chunks of heap memory are owned by a single pointer (red black trees, singly-linked lists, vectors, deques, circular queues, etc) can be represented easily in safe rust.Implementing a double-linked list is where things get tricky, as the nodes don't have a singular owner.