generational_indextree/lib.rs
1//! # Arena based tree data structure
2//!
3//! This arena tree structure is using just a single `GenerationalArena` and
4//! indices in the arena 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 generational_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
31pub use crate::{
32 arena::Arena,
33 error::NodeError,
34 id::NodeId,
35 node::Node,
36 traverse::{
37 Ancestors, Children, Descendants, FollowingSiblings, NodeEdge, PrecedingSiblings,
38 ReverseChildren, ReverseTraverse, Traverse,
39 },
40};
41
42#[macro_use]
43pub(crate) mod relations;
44
45mod arena;
46pub(crate) mod error;
47mod id;
48mod node;
49pub(crate) mod siblings_range;
50mod traverse;