use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Ordinal(u32);
impl Ordinal {
#[must_use]
pub const fn new(index: u32) -> Self {
Self(index)
}
#[must_use]
pub const fn index(self) -> u32 {
self.0
}
#[must_use]
pub fn as_usize(self) -> usize {
usize::try_from(self.0).unwrap_or(usize::MAX)
}
}
impl fmt::Display for Ordinal {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "#{}", self.0)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct EdgeKind(u32);
impl EdgeKind {
#[must_use]
pub const fn new(index: u32) -> Self {
Self(index)
}
#[must_use]
pub const fn index(self) -> u32 {
self.0
}
}
impl fmt::Display for EdgeKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "kind#{}", self.0)
}
}
#[must_use]
pub fn to_usize(value: u32) -> usize {
usize::try_from(value).unwrap_or(usize::MAX)
}