Ignore unreached tokens on a forked input stream
diff --git a/src/parse.rs b/src/parse.rs
index 1ad1e9b..2525d8f 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -26,7 +26,6 @@
pub type ParseStream<'a> = &'a ParseBuffer<'a>;
/// Cursor position within a buffered token stream.
-#[derive(Clone)]
pub struct ParseBuffer<'a> {
scope: Span,
cell: Cell<Cursor<'static>>,
@@ -42,6 +41,19 @@
}
}
+impl<'a> Clone for ParseBuffer<'a> {
+ fn clone(&self) -> Self {
+ ParseBuffer {
+ scope: self.scope,
+ cell: self.cell.clone(),
+ marker: PhantomData,
+ // Not the parent's unexpected. Nothing cares whether the clone
+ // parses all the way.
+ unexpected: Rc::new(Cell::new(None)),
+ }
+ }
+}
+
// Not public API.
#[doc(hidden)]
#[derive(Copy, Clone)]