diff options
author | Edwin Cheng <[email protected]> | 2019-04-23 19:59:38 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-04-25 19:03:55 +0100 |
commit | e4e2338f97d734624fb21b7972c73288ca04e65e (patch) | |
tree | 0282cab25534ba75976c690e003c7c8a095b3c73 /crates/ra_mbe/src/tt_cursor.rs | |
parent | 5bbd9f43cc217a44445fde91b4b53ca85d78cd92 (diff) |
Fix incorrect repeat sep eating
Diffstat (limited to 'crates/ra_mbe/src/tt_cursor.rs')
-rw-r--r-- | crates/ra_mbe/src/tt_cursor.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/tt_cursor.rs b/crates/ra_mbe/src/tt_cursor.rs index 741b5ea1c..87bcf8b0d 100644 --- a/crates/ra_mbe/src/tt_cursor.rs +++ b/crates/ra_mbe/src/tt_cursor.rs | |||
@@ -7,6 +7,10 @@ pub(crate) struct TtCursor<'a> { | |||
7 | pos: usize, | 7 | pos: usize, |
8 | } | 8 | } |
9 | 9 | ||
10 | pub(crate) struct TtCursorMemento { | ||
11 | pos: usize, | ||
12 | } | ||
13 | |||
10 | impl<'a> TtCursor<'a> { | 14 | impl<'a> TtCursor<'a> { |
11 | pub(crate) fn new(subtree: &'a tt::Subtree) -> TtCursor<'a> { | 15 | pub(crate) fn new(subtree: &'a tt::Subtree) -> TtCursor<'a> { |
12 | TtCursor { subtree, pos: 0 } | 16 | TtCursor { subtree, pos: 0 } |
@@ -157,4 +161,13 @@ impl<'a> TtCursor<'a> { | |||
157 | Err(ParseError::Expected(format!("`{}`", char))) | 161 | Err(ParseError::Expected(format!("`{}`", char))) |
158 | } | 162 | } |
159 | } | 163 | } |
164 | |||
165 | #[must_use] | ||
166 | pub(crate) fn save(&self) -> TtCursorMemento { | ||
167 | TtCursorMemento { pos: self.pos } | ||
168 | } | ||
169 | |||
170 | pub(crate) fn rollback(&mut self, memento: TtCursorMemento) { | ||
171 | self.pos = memento.pos; | ||
172 | } | ||
160 | } | 173 | } |