rstd::colections::tree
This commit is contained in:
parent
d49c8a7133
commit
be6924fe4c
@ -3,3 +3,4 @@
|
||||
pub mod avl;
|
||||
pub mod pair;
|
||||
pub mod stack;
|
||||
pub mod tree;
|
||||
|
40
src/rstd/collections/tree.rs
Normal file
40
src/rstd/collections/tree.rs
Normal file
@ -0,0 +1,40 @@
|
||||
use std::{error::Error, fmt::Display};
|
||||
|
||||
use crate::rstd::{atomic::au64::*, point::*};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum TreeParseError<E> {
|
||||
Int(IntParseError),
|
||||
Point(PointParseError),
|
||||
Key(E),
|
||||
}
|
||||
|
||||
impl<E> From<IntParseError> for TreeParseError<E> {
|
||||
fn from(value: IntParseError) -> Self {
|
||||
Self::Int(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E> From<PointParseError> for TreeParseError<E> {
|
||||
fn from(value: PointParseError) -> Self {
|
||||
Self::Point(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Display> Display for TreeParseError<E> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Int(int_error) => {
|
||||
write!(f, "failed to parse AVL tree height: {int_error}")
|
||||
}
|
||||
Self::Point(point_error) => {
|
||||
write!(f, "failed to parse AVL node reference: {point_error}")
|
||||
}
|
||||
Self::Key(key_error) => {
|
||||
write!(f, "failed to parse AVL node key: {key_error}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Error> Error for TreeParseError<E> {}
|
Loading…
Reference in New Issue
Block a user