indextree/
lib.rs

1//! # Arena based tree data structure
2//!
3//! This arena tree structure is using just a single `Vec` and numerical
4//! identifiers (indices in the vector) instead of reference counted pointers
5//! like. This means there is no `RefCell` and mutability is handled in a way
6//! much more idiomatic to Rust through unique (&mut) access to the arena. The
7//! tree can be sent or shared across threads like a `Vec`. This enables
8//! general multiprocessing support like parallel tree traversals.
9//!
10//! # Example usage
11//! ```
12//! use indextree::Arena;
13//!
14//! // Create a new arena
15//! let arena = &mut Arena::new();
16//!
17//! // Add some new nodes to the arena
18//! let a = arena.new_node(1);
19//! let b = arena.new_node(2);
20//!
21//! // Append b to a
22//! a.append(b, arena);
23//! assert_eq!(b.ancestors(arena).into_iter().count(), 2);
24//! ```
25#![forbid(unsafe_code)]
26#![cfg_attr(not(feature = "std"), no_std)]
27
28#[cfg(not(feature = "std"))]
29extern crate alloc;
30
31#[allow(deprecated)]
32pub use crate::{
33    arena::Arena,
34    debug_pretty_print::DebugPrettyPrint,
35    error::NodeError,
36    id::NodeId,
37    node::Node,
38    traverse::{
39        Ancestors, Children, Descendants, FollowingSiblings, NodeEdge, PrecedingSiblings,
40        Predecessors, ReverseChildren, ReverseTraverse, Traverse,
41    },
42};
43
44#[cfg(feature = "macros")]
45pub use indextree_macros as macros;
46
47#[macro_use]
48pub(crate) mod relations;
49
50mod arena;
51mod debug_pretty_print;
52pub(crate) mod error;
53mod id;
54mod node;
55pub(crate) mod siblings_range;
56mod traverse;