protobuf_support/lexer/
loc.rs

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