use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct CycleDepth(u16);
impl CycleDepth {
pub fn new(depth: u16) -> Self {
Self(depth)
}
pub fn first() -> Self {
Self(1)
}
pub fn increment(self) -> Self {
Self(self.0.saturating_add(1))
}
pub fn as_u16(self) -> u16 {
self.0
}
}
impl fmt::Display for CycleDepth {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}