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