1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#[derive(Debug, Clone, Default)] pub struct SourceLine { pub start: usize, pub end: usize, pub ends_with_eof: bool, } impl SourceLine { pub fn len(&self) -> usize { self.end - self.start } pub fn line_end(&self) -> usize { let mut result = self.end; if !self.ends_with_eof { result -= 1 // exclude trailing \n } result } }