3 ms·
struct list_head { struct list_head *next, *prev; }; I'd done a few Rust tutorials before I thought to myself Hmmm, what's something basic I can tr
by SighMagi 4y ago
struct list_head {
struct list_head *next, *prev;
};
I'd done a few Rust tutorials before I thought to myself Hmmm, what's something basic I can try making in Rust? I know, a linked list. Oh boy, was that a schooling...
- karmakurtisaani 4y agoHaha, yep. Now for added challenge make it doubly linked to run into ownership issues (if you didn't already). I do like the language, but damn it forces you think carefully what you're doing.
- infamouscow 4y agoThe Linux kernel uses intrusive data structures to avoid a superfluous memory allocation and cache-friendliness. There's also an intrusive Red-black tree and Radix tree implementation in the kernel.
- _0w8t 4y agoA linked list is not cache friendly unless the nodes are allocated mostly nearby. But if one can ensure such allocation, then why not to use an array or at least a list of small arrays?
- megous 4y agoThe kernel uses struct embedding for puting structs into lists. You can't do that with an array.
- rhn_mk1 4y agoTo anyone wondering what kind of schooling exactly it is: https://rust-unofficial.github.io/too-many-lists/ https://rust-unofficial.github.io/too-many-lists/