Encapsulate position
This commit is contained in:
@@ -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> {
|
||||||
|
|||||||
Reference in New Issue
Block a user