diff options
Diffstat (limited to 'chewed/src/parse.rs')
-rw-r--r-- | chewed/src/parse.rs | 8 |
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>; |