1
0
dust/dust-lang/src/identifier.rs
2024-03-25 00:16:55 -04:00

24 lines
481 B
Rust

use std::{
fmt::{self, Display, Formatter},
sync::Arc,
};
#[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
pub struct Identifier(Arc<String>);
impl Identifier {
pub fn new<T: ToString>(string: T) -> Self {
Identifier(Arc::new(string.to_string()))
}
pub fn as_str(&self) -> &str {
self.0.as_str()
}
}
impl Display for Identifier {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}