summaryrefslogtreecommitdiff
path: root/chewed/src/parse.rs
diff options
context:
space:
mode:
authorGreg Brown <gmb60@cam.ac.uk>2021-01-07 12:44:06 +0000
committerGreg Brown <gmb60@cam.ac.uk>2021-01-07 12:44:06 +0000
commitfe2eac31d9dbec772796c3ea75be32e9cd01b810 (patch)
treead0c0ad42ce986d3dd915512de8c18968194c15a /chewed/src/parse.rs
parenteb280a903f8f20d0b0c0ef5acae955a20929d100 (diff)
Add first steps of AutoChomp
Diffstat (limited to 'chewed/src/parse.rs')
-rw-r--r--chewed/src/parse.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/chewed/src/parse.rs b/chewed/src/parse.rs
index 0687ea5..f6bbd66 100644
--- a/chewed/src/parse.rs
+++ b/chewed/src/parse.rs
@@ -1,3 +1,5 @@
+use std::iter::Peekable;
+
use super::error::{ParseError, TakeError};
pub trait Parser: Iterator<Item = char> {
@@ -37,6 +39,12 @@ pub trait Parser: Iterator<Item = char> {
}
}
+impl<I: Iterator<Item = char>> Parser for Peekable<I> {
+ fn peek(&mut self) -> Option<char> {
+ Peekable::peek(self).copied()
+ }
+}
+
pub trait Parse: Sized {
fn take<P: Parser + ?Sized>(input: &mut P) -> Result<Self, TakeError>;