use std::{borrow::Borrow, fmt, rc::Rc};

#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct IdentifierValue(Rc<str>);

impl From<&str> for IdentifierValue {
    fn from(value: &str) -> Self {
        Self(value.into())
    }
}

impl From<String> for IdentifierValue {
    fn from(value: String) -> Self {
        Self(value.into())
    }
}

impl AsRef<str> for IdentifierValue {
    fn as_ref(&self) -> &str {
        self.0.as_ref()
    }
}

impl Borrow<str> for IdentifierValue {
    fn borrow(&self) -> &str {
        self.as_ref()
    }
}

impl fmt::Display for IdentifierValue {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.0)
    }
}
