40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use std::marker::PhantomData;
|
|
use crate::pos::{PosCounter};
|
|
use crate::{CollectedSubstring, Predicate, SourceStream};
|
|
|
|
pub struct EmptySourceStream<C: Copy, CS: CollectedSubstring<C = C>, PC: PosCounter<C>> {
|
|
_pos: PC,
|
|
__phantom: PhantomData<(C, CS)>
|
|
}
|
|
|
|
impl<C: Copy, CS: CollectedSubstring<C = C>, PC: PosCounter<C>> EmptySourceStream<C, CS, PC> {
|
|
pub fn start(pos: PC) -> (Self, Option<C>) {
|
|
let stream = EmptySourceStream { _pos: pos, __phantom: PhantomData::default() };
|
|
return (stream, None);
|
|
}
|
|
}
|
|
|
|
impl<C: Copy, CS: CollectedSubstring<C = C>, PC: PosCounter<C>> SourceStream
|
|
for EmptySourceStream<C, CS, PC>
|
|
{
|
|
type C = C;
|
|
type P = PC::P;
|
|
type CS = CS;
|
|
|
|
fn skipNext(&mut self, _: &mut impl Predicate<Self::C>) -> Option<Self::C> {
|
|
return None;
|
|
}
|
|
|
|
fn collect(&mut self, _: &mut impl Predicate<Self::C>) -> (Self::CS, Option<Self::C>) {
|
|
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<Self::C> {
|
|
return None;
|
|
}
|
|
}
|