From 07edc4f047dda35a2e1ffb53e5254802463a8c74 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 3 Aug 2023 13:57:39 -0700 Subject: [PATCH] Minor tweaks --- src/parser/linelocation.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/parser/linelocation.rs b/src/parser/linelocation.rs index c48a203..3d9b322 100644 --- a/src/parser/linelocation.rs +++ b/src/parser/linelocation.rs @@ -15,12 +15,20 @@ impl LineLocation { pub fn zero(&self) -> bool { return self.pos == 0 && self.len == 0 } + + pub fn new_zero() -> LineLocation { + return LineLocation { pos: 0, len: 0} + } + + pub fn cut_string<'a>(&self, s: &'a String) -> &'a str { + &s[self.pos..self.pos+self.len] + } } impl PartialEq for LineLocation { fn eq(&self, other: &Self) -> bool { self.pos == other.pos && - self.len ==other.len + self.len == other.len } }