1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
use crate::*; use std::marker::PhantomData; #[derive(Debug, Clone)] pub struct Any<T: Clone>(PhantomData<T>); impl<T: Clone> Any<T> { pub(crate) fn new() -> Self { Self(PhantomData) } } impl<T: Clone> Scanner for Any<T> { type Input = T; type Output = T; fn scan(&self, stream: &mut Stream<Self::Input>) -> Res<Self> { let val = stream .peek() .ok_or_else(|| Error::new(stream.pos(), None, Expected::Any))?; stream.next(); Ok(val) } }