Encapsulate position

This commit is contained in:
Aleksey Kladov
2018-01-11 23:25:14 +03:00
parent 9a8e9bc4c6
commit 15ae9026cf

View File

@@ -19,6 +19,9 @@ pub(crate) struct Parser<'t> {
curly_limit: Option<i32>, curly_limit: Option<i32>,
} }
#[derive(Debug, Clone, Copy,PartialEq, Eq)]
pub(crate) struct Pos(u32);
impl<'t> Parser<'t> { impl<'t> Parser<'t> {
pub(crate) fn new(text: &'t str, raw_tokens: &'t [Token]) -> Parser<'t> { pub(crate) fn new(text: &'t str, raw_tokens: &'t [Token]) -> Parser<'t> {
let mut tokens = Vec::new(); let mut tokens = Vec::new();
@@ -44,8 +47,8 @@ impl<'t> Parser<'t> {
} }
} }
pub(crate) fn pos(&self) -> usize { pub(crate) fn pos(&self) -> Pos {
self.pos Pos(self.pos as u32)
} }
pub(crate) fn into_events(self) -> Vec<Event> { pub(crate) fn into_events(self) -> Vec<Event> {