use std::fmt;
#[derive(
Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
)]
#[serde(transparent)]
pub struct LawVersion(u32);
impl LawVersion {
#[must_use]
pub const fn new(version: u32) -> Self {
Self(version)
}
#[must_use]
pub const fn get(self) -> u32 {
self.0
}
}
impl fmt::Display for LawVersion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "v{}", self.0)
}
}
#[derive(
Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
)]
#[non_exhaustive]
pub enum TerminationCriterion {
WeaklyAcyclic,
}
impl TerminationCriterion {
#[must_use]
pub const fn label(self) -> &'static str {
match self {
Self::WeaklyAcyclic => "weakly-acyclic",
}
}
#[must_use]
pub const fn law_version(self) -> LawVersion {
match self {
Self::WeaklyAcyclic => LawVersion::new(1),
}
}
}
impl fmt::Display for TerminationCriterion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} {}", self.label(), self.law_version())
}
}