pathtree 0.1.0

An immutable tree data structure for fast path operations
Documentation
  • Coverage
  • 100%
    10 out of 10 items documented1 out of 9 items with examples
  • Size
  • Source code size: 8.86 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.35 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rohanku

Pathtree

An immutable tree data structure for fast path operations.

PathTree is inexpensive to clone and supports prepending and appending paths to one another. Useful when several objects in a tree need to store their path relative to the root.

Usage

use pathtree::PathTree;


let path = PathTree::empty();
let path = path.append_segment(7);
let path = path.append_segment(5);
let path = path.prepend_segment(6);
let path = path.prepend_segment(8);

let path_vec: Vec<_> = path.iter().copied().collect();
assert_eq!(path_vec, vec![8, 6, 7, 5]);

let other_path = PathTree::empty();

let other_path = other_path.append_segment(2);
let other_path = other_path.prepend_segment(1);
let other_path = other_path.append_segment(3);
let other_path = other_path.prepend_segment(4);

let full_path = other_path.append(&path);
let full_path_vec: Vec<_> = full_path.iter().copied().collect();
assert_eq!(full_path_vec, vec![4, 1, 2, 3, 8, 6, 7, 5]);