[−][src]Macro fumio_utils::local_dl_list
Create a "link" and "head" datatype for a non thread-safe double linked list; the "link" type must be used in a data structure as member.
The list itself doesn't manage any ownership / reference counts, which is why most
modifications are unsafe
, and returned nodes are raw pointers.
Example
fn main() { mod example { fumio_utils::local_dl_list! { pub mod ex1 { link TestLink; head TestHead; member link of Test; } } pub struct Test { link: TestLink, pub value: usize, } impl Test { pub fn new(value: usize) -> Self { Test { link: TestLink::new(), value, } } } } use example::*; let head = TestHead::new(); let node1 = Test::new(1); let node2 = Test::new(2); unsafe { head.append(&node1); head.append(&node2); assert_eq!( { &*head.pop_front().unwrap() }.value, 1); assert_eq!( { &*head.pop_front().unwrap() }.value, 2); } }