use std::sync::Arc;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Origin {
pub file: Arc<str>,
pub line: u32,
pub column: u32,
}
impl Origin {
#[must_use]
pub fn new(file: impl Into<Arc<str>>, line: u32, column: u32) -> Self {
Self {
file: file.into(),
line,
column: column.max(1),
}
}
#[must_use]
pub fn display(&self) -> String {
if self.column <= 1 {
format!("{}:{}", self.file, self.line)
} else {
format!("{}:{}:{}", self.file, self.line, self.column)
}
}
}