dust/dust-lang/src/identifier.rs

24 lines
481 B
Rust
Raw Normal View History

2024-03-25 04:16:55 +00:00
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)
}
}