use std::fmt;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Depth(u32);
impl Depth {
pub const ROOT: Self = Self(0);
#[must_use]
pub const fn new(depth: u32) -> Self {
Self(depth)
}
#[must_use]
pub const fn get(self) -> u32 {
self.0
}
#[must_use]
pub const fn child(self) -> Self {
Self(self.0.saturating_add(1))
}
}
impl fmt::Display for Depth {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}