diff --git a/src/common.rs b/src/common.rs index a1bf3ac1..3b4dd100 100644 --- a/src/common.rs +++ b/src/common.rs @@ -2,13 +2,15 @@ use std::fmt; +pub(crate) type PosUInt = u32; + /// Represents a position inside some textual document. #[derive(Copy, Clone, PartialEq, Eq)] pub struct TextPosition { /// Row, counting from 0 - pub row: u64, + pub row: PosUInt, /// Column, counting from 0 - pub column: u64, + pub column: PosUInt, } impl TextPosition { @@ -22,13 +24,13 @@ impl TextPosition { /// Advances the position in a line #[inline] pub fn advance(&mut self, count: u8) { - self.column += u64::from(count); + self.column += PosUInt::from(count); } /// Advances the position in a line to the next tab position #[inline] pub fn advance_to_tab(&mut self, width: u8) { - let width = u64::from(width); + let width = PosUInt::from(width); self.column += width - self.column % width; } diff --git a/src/reader/lexer.rs b/src/reader/lexer.rs index f6ce5fe9..33416891 100644 --- a/src/reader/lexer.rs +++ b/src/reader/lexer.rs @@ -649,6 +649,7 @@ impl Lexer { #[cfg(test)] mod tests { + use crate::common::PosUInt; use crate::common::Position; use std::io::{BufReader, Cursor}; @@ -667,8 +668,8 @@ mod tests { let err = $lex.next_token(&mut $buf); assert!(err.is_err()); let err = err.unwrap_err(); - assert_eq!($r as u64, err.position().row); - assert_eq!($c as u64, err.position().column); + assert_eq!($r as PosUInt, err.position().row); + assert_eq!($c as PosUInt, err.position().column); }) );