diff options
author | Aleksey Kladov <[email protected]> | 2018-01-11 20:25:14 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-11 20:25:14 +0000 |
commit | 15ae9026cf270d898cad16678032a5460e77404c (patch) | |
tree | 7df6187b7075a01c728d6a363bdea7f5010c72ca | |
parent | 9a8e9bc4c6339051ef260f7794603481b6ff0bf2 (diff) |
Encapsulate position
-rw-r--r-- | src/parser/event_parser/parser.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/parser/event_parser/parser.rs b/src/parser/event_parser/parser.rs index d7d24fa27..8bc382b12 100644 --- a/src/parser/event_parser/parser.rs +++ b/src/parser/event_parser/parser.rs | |||
@@ -19,6 +19,9 @@ pub(crate) struct Parser<'t> { | |||
19 | curly_limit: Option<i32>, | 19 | curly_limit: Option<i32>, |
20 | } | 20 | } |
21 | 21 | ||
22 | #[derive(Debug, Clone, Copy,PartialEq, Eq)] | ||
23 | pub(crate) struct Pos(u32); | ||
24 | |||
22 | impl<'t> Parser<'t> { | 25 | impl<'t> Parser<'t> { |
23 | pub(crate) fn new(text: &'t str, raw_tokens: &'t [Token]) -> Parser<'t> { | 26 | pub(crate) fn new(text: &'t str, raw_tokens: &'t [Token]) -> Parser<'t> { |
24 | let mut tokens = Vec::new(); | 27 | let mut tokens = Vec::new(); |
@@ -44,8 +47,8 @@ impl<'t> Parser<'t> { | |||
44 | } | 47 | } |
45 | } | 48 | } |
46 | 49 | ||
47 | pub(crate) fn pos(&self) -> usize { | 50 | pub(crate) fn pos(&self) -> Pos { |
48 | self.pos | 51 | Pos(self.pos as u32) |
49 | } | 52 | } |
50 | 53 | ||
51 | pub(crate) fn into_events(self) -> Vec<Event> { | 54 | pub(crate) fn into_events(self) -> Vec<Event> { |