1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
use std::fmt;
pub const FIRST_LINE: u32 = 1;
pub const FIRST_COL: u32 = 1;
/// Location in file
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub struct Loc {
/// 1-based
pub line: u32,
/// 1-based
pub col: u32,
}
impl fmt::Display for Loc {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}:{}", self.line, self.col)
}
}
impl Loc {
pub fn start() -> Loc {
Loc {
line: FIRST_LINE,
col: FIRST_COL,
}
}
}