use std::borrow::Cow;
mod as_ref;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct VariableId(Cow<'static, str>);
#[derive(Clone, Debug)]
pub struct InvalidVariableId(pub Cow<'static, str>);
impl VariableId {
pub const fn is_valid(_: &str) -> bool {
true
}
pub fn try_create<Id>(id: Id) -> Result<Self, InvalidVariableId>
where
Id: AsRef<str>,
{
Ok(VariableId(Cow::Owned(id.as_ref().into())))
}
pub const fn unsafe_create(id: &'static str) -> Self {
if Self::is_valid(id) {
VariableId(Cow::Borrowed(id))
} else {
panic!("Invalid rule id");
}
}
}