Re:Things you can’t do in Rust (and what to do instead)
by staticassertion on Saturday May 15, 2021 @10:04PM
(#27170608)
Or a Vec<T> for storage and a Vec<usize> for tombstoning. Lots of ways to solve this, and my experience is that you can beat a linked list approach with the 'Vec plus Vec' approach for a lot of data sizes/ operations.
Or a custom Vec that has a lower maximum bound, at which point you can start doing things like integer encoding/ pointer swizzling.
Re:Things you can’t do in Rust (and what to do instead)
by mousepilot on Saturday May 15, 2021 @08:52PM
(#27170281)
I probably shouldn't even be in this thread but isn't that creeping back toward garbage collection?
Re:Things you can’t do in Rust (and what to do instead)
by masklinn on Sunday May 16, 2021 @02:17AM
(#27171608)
It’s completely normal to have this sort of things in low-level code bases. Both C++ and Rust have refcounting smart pointers in their standard libraries, and bespoke refcounting schemes are regular occurrences in C codebases (the Linux kernel has tons of refcounting, so much so that it has a utility file for reference counters: https://github.com/torvalds/linux/blob/master/include/linux/...)
Re:Things you can’t do in Rust (and what to do instead)
by mousepilot on Monday May 17, 2021 @10:18AM
(#27183695)
thanks for the response!
I'm a big fan of doubly linked lists, so it was interesting to see that there was extra work to get them going. I'm certainly going to read up on this "ownership" thing. I get the impression that its there for really good reasons, and I'm not going to argue with experts who are protecting users.
I have a question for you, would you say that the increase of difficulties with doubly linked lists are incidental in nature, or is there something inherent with doubly linked lists that impact security? Like I said, I like the doubly linked lists for certain things, and the more I know about the impact of using them the better!
I certainly will be reading up on this!
Re:Things you can’t do in Rust (and what to do instead)
by staticassertion on Saturday May 15, 2021 @10:03PM
(#27170599)
Sure, it's just a mark and sweep, but manually implemented (which is fine).
FWIW the original suggestion mentioned tombstoning so you'd have a Vec<Option<T>> instead of a `Vec<T>`, and "removing" an item would just set the `Option` to `None`.
Of course this would increase iteration cost (as you'd have to skip the `None`), and you'd probably want to compact the vec once in a while.