mod debug_print;
mod edit;
mod frozen;
mod hot;
mod internal;
mod membership;
mod plain;
use core::cell::BorrowError;
use core::fmt;
pub(crate) use self::debug_print::DebugPrintSubtreeDescendant;
pub use self::debug_print::{DebugPrettyPrint, DebugPrintNodeLocal, DebugPrintSubtree};
pub use self::frozen::FrozenNode;
pub use self::hot::HotNode;
use self::internal::NodeCoreLinkWeak;
pub(crate) use self::internal::{NodeCoreLink, NodeLink};
pub use self::plain::{Node, NodeWeak};
#[derive(Debug)]
#[non_exhaustive]
pub enum HierarchyError {
AncestorDescendantLoop,
EmptyTree,
SiblingsWithoutParent,
BorrowNodeData(BorrowError),
}
impl fmt::Display for HierarchyError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let msg = match *self {
Self::AncestorDescendantLoop => "attempt to make a node its own descendant or ancestor",
Self::EmptyTree => "attempt to make a tree empty",
Self::SiblingsWithoutParent => "attempt to make a node sibling of the root node",
Self::BorrowNodeData(_) => "failed to borrow the data associated to the node",
};
f.write_str(msg)
}
}
#[cfg(feature = "std")]
impl std::error::Error for HierarchyError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::BorrowNodeData(e) => Some(e),
_ => None,
}
}
}