aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/tt_cursor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_mbe/src/tt_cursor.rs')
-rw-r--r--crates/ra_mbe/src/tt_cursor.rs13
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
10pub(crate) struct TtCursorMemento {
11 pos: usize,
12}
13
10impl<'a> TtCursor<'a> { 14impl<'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}