use std::str::FromStr;
#[derive(PartialEq, Eq, Debug)]
pub struct InvalidCharacter(pub char);
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Condition(Box<str>);
impl Condition {
#[must_use]
pub fn new(name: &str) -> Self {
Self(name.into())
}
}
impl FromStr for Condition {
type Err = InvalidCharacter;
fn from_str(name: &str) -> Result<Self, InvalidCharacter> {
if let Some(c) = name.chars().find(|&c| !c.is_alphanumeric() && c != ' ') {
return Err(InvalidCharacter(c));
}
Ok(Self(name.into()))
}
}