use std::{borrow::Cow, fmt};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InvariantViolation {
pub name: Cow<'static, str>,
pub detail: String,
}
impl InvariantViolation {
pub fn new(name: impl Into<Cow<'static, str>>, detail: impl Into<String>) -> Self {
Self {
name: name.into(),
detail: detail.into(),
}
}
}
impl fmt::Display for InvariantViolation {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}: {}", self.name, self.detail)
}
}