use { crate::utils::{ clonecell::UnsafeCellCloneSafe, opaque::{OPAQUE_LEN, Opaque, OpaqueError, opaque}, }, arrayvec::ArrayString, std::{ fmt::{Display, Formatter}, str::FromStr, }, }; #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash, Ord, PartialOrd)] pub struct ToplevelIdentifier(Opaque); unsafe impl UnsafeCellCloneSafe for ToplevelIdentifier {} pub fn toplevel_identifier() -> ToplevelIdentifier { ToplevelIdentifier(opaque()) } impl ToplevelIdentifier { pub fn to_string(self) -> ArrayString { self.0.to_string() } } impl Display for ToplevelIdentifier { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } impl FromStr for ToplevelIdentifier { type Err = OpaqueError; fn from_str(s: &str) -> Result { Ok(Self(s.parse()?)) } }