diff options
Diffstat (limited to 'chewed/src/position.rs')
-rw-r--r-- | chewed/src/position.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/chewed/src/position.rs b/chewed/src/position.rs new file mode 100644 index 0000000..62d9b5a --- /dev/null +++ b/chewed/src/position.rs @@ -0,0 +1,21 @@ +use std::fmt; + +#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] +pub struct LineCol { + /// One-indexed line. + pub line: usize, + /// Zero-indexed column. + pub col: usize, +} + +impl Default for LineCol { + fn default() -> Self { + Self { line: 1, col: 0 } + } +} + +impl fmt::Display for LineCol { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}:{}", self.line, self.col) + } +} |