diff options
Diffstat (limited to 'src/lexer/ptr.rs')
-rw-r--r-- | src/lexer/ptr.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lexer/ptr.rs b/src/lexer/ptr.rs index ff6ef11fc..99d55b283 100644 --- a/src/lexer/ptr.rs +++ b/src/lexer/ptr.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use {TextUnit}; | 1 | use TextUnit; |
2 | 2 | ||
3 | use std::str::Chars; | 3 | use std::str::Chars; |
4 | 4 | ||
@@ -9,7 +9,10 @@ pub(crate) struct Ptr<'s> { | |||
9 | 9 | ||
10 | impl<'s> Ptr<'s> { | 10 | impl<'s> Ptr<'s> { |
11 | pub fn new(text: &'s str) -> Ptr<'s> { | 11 | pub fn new(text: &'s str) -> Ptr<'s> { |
12 | Ptr { text, len: TextUnit::new(0) } | 12 | Ptr { |
13 | text, | ||
14 | len: TextUnit::new(0), | ||
15 | } | ||
13 | } | 16 | } |
14 | 17 | ||
15 | pub fn into_len(self) -> TextUnit { | 18 | pub fn into_len(self) -> TextUnit { |
@@ -53,7 +56,7 @@ impl<'s> Ptr<'s> { | |||
53 | match self.next() { | 56 | match self.next() { |
54 | Some(c) if pred(c) => { | 57 | Some(c) if pred(c) => { |
55 | self.bump(); | 58 | self.bump(); |
56 | }, | 59 | } |
57 | _ => return, | 60 | _ => return, |
58 | } | 61 | } |
59 | } | 62 | } |
@@ -66,6 +69,6 @@ impl<'s> Ptr<'s> { | |||
66 | 69 | ||
67 | fn chars(&self) -> Chars { | 70 | fn chars(&self) -> Chars { |
68 | let len: u32 = self.len.into(); | 71 | let len: u32 = self.len.into(); |
69 | self.text[len as usize ..].chars() | 72 | self.text[len as usize..].chars() |
70 | } | 73 | } |
71 | } | 74 | } |