use std::marker::PhantomData; use crate::{CollectedSubstring, Pos, Predicate, SourceStream}; use crate::pos::PosCounter; pub struct EmptySourceStream< 'source, 'pos, C: Copy, P: Pos<'pos>, CS: CollectedSubstring<'source, C=C>, PC: PosCounter<'pos, C, P=P>, > { _pos: PC, __phantom: PhantomData<(&'source (), &'pos (), P, CS)>, } impl< 'source, 'pos, C: Copy, P: Pos<'pos>, CS: CollectedSubstring<'source, C=C>, PC: PosCounter<'pos, C, P=P>, > EmptySourceStream<'source, 'pos, C, P, CS, PC> { pub fn start(pos: PC) -> (Self, Option) { let stream = EmptySourceStream { _pos: pos, __phantom: PhantomData::default() }; return (stream, None); } } impl< 'source, 'pos, C: Copy, P: Pos<'pos>, CS: CollectedSubstring<'source, C=C>, PC: PosCounter<'pos, C, P=P>, > SourceStream<'source, 'pos> for EmptySourceStream<'source, 'pos, C, P, CS, PC> { type C = C; type P = P; type CS = CS; fn skipNext(&mut self, predicate: &mut impl Predicate) -> Option { return None; } fn collect(&mut self, predicate: &mut impl Predicate) -> (Self::CS, Option) { panic!("How about to check first char of substring being collected first"); } fn pos(&self) -> Self::P { return self._pos.export(); } fn nextChar(&mut self) -> Option { return None; } }