Hacker News new | ask | show | jobs
by thayne 540 days ago
It doesn't though.

Those are fairly straightforward to implement if you are ok using a reference counted type (along with weak references), although that will hurt performance. That would be similar to using a shared_pointer in c++.

And you can implement code similar to what you would in c or c++ if you use raw pointers and unsafe code.

Where you run into difficulties is if you want something that is fast and safe. And then you need a more complicated design that probably involves using indices into a Vec instead of pointers.

1 comments

Using a Vec for doubly linked lists sounds like overkill. There's got to be more efficient and more elegant way.
Using a Vec actually has some benefits beyond the safety guarantees from rust. There are fewer allocations, and you probably are more likely to get nearby nodes on the same cache line.
Yes, there is, just use plain old pointers. Who cares about UB anyway.