use crate::{
nameable,
protocol::{walker::HintMeta, ControlFlow, Visitor},
};
pub trait Sequence<'ctx> {
fn visit(&mut self, scope: &mut dyn SequenceScope<'ctx>) -> ControlFlow;
}
nameable! {
pub struct Name['a, 'ctx];
impl for dyn Sequence<'ctx> + 'a where { 'ctx: 'a }
impl where dyn Sequence<'ctx> + 'a { 'ctx: 'a }
}
pub trait SequenceScope<'ctx> {
fn next(&mut self, visitor: Visitor<'_, 'ctx>) -> ControlFlow<(), Status>;
}
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Debug)]
pub enum Status {
Done,
Continue,
}
#[derive(Default)]
pub struct Known {
pub len: (usize, Option<usize>),
}
pub struct Hint {
pub len: (usize, Option<usize>),
}
impl<'ctx> HintMeta<'ctx> for dyn Sequence<'ctx> + '_ {
type Known<'a> = Known
where
'ctx: 'a;
type Hint = Hint;
}