use std::{fmt, ops::Deref, rc::Rc};

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

impl StringValue {
    pub fn as_rc_str(&self) -> &Rc<str> {
        &self.0
    }
}

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

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

impl Deref for StringValue {
    type Target = str;

    fn deref(&self) -> &Self::Target {
        self.0.as_ref()
    }
}

impl fmt::Display for StringValue {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Debug::fmt(self.0.as_ref(), f)
    }
}
