Diffstat (limited to 'src/protocol/visitor/sequence.rs')
| -rw-r--r-- | src/protocol/visitor/sequence.rs | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/protocol/visitor/sequence.rs b/src/protocol/visitor/sequence.rs index b143c12..3cb8897 100644 --- a/src/protocol/visitor/sequence.rs +++ b/src/protocol/visitor/sequence.rs @@ -1,27 +1,26 @@ - use crate::{ - builtins::walker::hint::Meta, - protocol::{Implementer, Protocol}, + nameable, + protocol::{walker::HintMeta, ControlFlow, Visitor}, }; -pub enum Sequence {} - -#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Debug)] -pub enum Status { - Done, - Continue, +pub trait Sequence<'ctx> { + fn visit(&mut self, scope: &mut dyn SequenceScope<'ctx>) -> ControlFlow; } -pub trait SequenceWalker<'ctx> { - fn next(&mut self, visitor: &mut dyn Implementer<'ctx>) -> Result<Status, ()>; +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 Object<'ctx> { - fn visit(&mut self, walker: &mut dyn SequenceWalker<'ctx>) -> Result<(), ()>; +pub trait SequenceScope<'ctx> { + fn next(&mut self, visitor: Visitor<'_, 'ctx>) -> ControlFlow<(), Status>; } -impl Protocol for Sequence { - type Object<'a, 'ctx: 'a> = &'a mut dyn Object<'ctx>; +#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Debug)] +pub enum Status { + Done, + Continue, } #[derive(Default)] @@ -33,8 +32,10 @@ pub struct Hint { pub len: (usize, Option<usize>), } -impl Meta for Sequence { - type Known<'a, 'ctx: 'a> = Known; +impl<'ctx> HintMeta<'ctx> for dyn Sequence<'ctx> + '_ { + type Known<'a> = Known + where + 'ctx: 'a; - type Hint<'a, 'ctx: 'a> = Hint; + type Hint = Hint; } |