intrex 0.1.0

Intrusive doubly-linked lists with items addressed by indices
Documentation
  • Coverage
  • 100%
    56 out of 56 items documented1 out of 49 items with examples
  • Size
  • Source code size: 42.58 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.67 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • yvt

intrex

Intrusive doubly-linked lists with items stored in an application-provided object pool and addressed by indices.

use intrex::list::{Head, Link};

struct Node {
    value: i32,
    siblings: Option<Link>,
}

let mut nodes: Vec<_> = (0..4)
    .map(|value| Node { value, siblings: None })
    .collect();
let mut head = Head::default();

// Add [2, 3, 1, 0] to the list
let mut accessor = head
    .accessor_mut(&mut nodes, |n: &mut Node| &mut n.siblings);
accessor.push_back(3);
accessor.push_back(0);
accessor.insert(1, Some(0));
accessor.push_front(2);

// Inspect the list
let accessor = head.accessor(&nodes, |n| &n.siblings);
assert_eq!(accessor.front().unwrap().value, 2);
assert_eq!(accessor.back().unwrap().value, 0);
assert_eq!(
    accessor.values().map(|n| n.value).collect::<Vec<_>>(),
    vec![2, 3, 1, 0],
);

License

MIT/Apache-2.0