2023-01-20 16:10:03 +01:00
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
|
pub struct CodePos {
|
|
|
|
|
pub line: u32,
|
|
|
|
|
pub col: u32,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for CodePos {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self { line: 1, col: 0 }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-28 01:11:55 +01:00
|
|
|
impl std::fmt::Display for CodePos {
|
2023-01-20 16:10:03 +01:00
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
|
write!(f, "line {}, col {}", self.line, self.col)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-28 01:11:55 +01:00
|
|
|
impl std::fmt::Debug for CodePos {
|
2023-01-20 16:10:03 +01:00
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
|
write!(f, "{}:{}", self.line, self.col)
|
|
|
|
|
}
|
|
|
|
|
}
|