Diffstat (limited to 'src/walk/walkers/core/bool.rs')
| -rw-r--r-- | src/walk/walkers/core/bool.rs | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/walk/walkers/core/bool.rs b/src/walk/walkers/core/bool.rs index 0fd9cbd..b61f75b 100644 --- a/src/walk/walkers/core/bool.rs +++ b/src/walk/walkers/core/bool.rs @@ -1,51 +1,55 @@ -use crate::{any::static_wrapper::OwnedStatic, protocol::visitor::Value}; -use core::{mem::MaybeUninit, ops::ControlFlow}; +use crate::{any::static_wrapper::OwnedStatic, protocol::visitor::value::Value}; +use core::{marker::PhantomData, mem::MaybeUninit, ops::ControlFlow}; use crate::{ any_trait, - effect::{Effect, SyncEffect, Yield}, + effect::{Effect, Future}, protocol::{ - visitor::{RequestHint, Sequence, SequenceScope, Status}, - walker::{Hint, HintMeta}, + walker::hint::{Hint, HintMeta}, Visitor, }, }; impl<'ctx> crate::Walk<'ctx> for bool { - type Walker = Walker; -} - -pub struct Walker(bool); + type Walker<E: Effect<'ctx>> = Walker<E>; -impl<'ctx> From<bool> for Walker { - fn from(value: bool) -> Self { - Self(value) + fn into_walker<E: Effect<'ctx>>(self) -> Self::Walker<E> { + Walker(self, PhantomData) } } -impl<'ctx> crate::Walker<'ctx> for Walker { - type Effect = SyncEffect; +pub struct Walker<E>(bool, PhantomData<fn() -> E>); + +impl<'ctx> crate::WalkerTypes<'ctx> for bool { + type Error = (); + + type Output = (); +} +impl<'ctx, E: Effect<'ctx>> crate::WalkerTypes<'ctx> for Walker<E> { type Error = (); type Output = (); +} +impl<'ctx, E: Effect<'ctx>> crate::Walker<'ctx> for Walker<E> { + type Effect = E; #[inline] fn walk<'a>( self, - visitor: Visitor<'a, 'ctx, SyncEffect>, - ) -> Yield<'a, 'ctx, Result<Self::Output, Self::Error>, Self::Effect> + visitor: Visitor<'a, 'ctx>, + ) -> Future<'a, 'ctx, Result<Self::Output, Self::Error>, E> where 'ctx: 'a, { - { + E::wrap(async move { if let Some(object) = - visitor.upcast_mut::<dyn Value<'_, '_, OwnedStatic<bool>, SyncEffect> + '_>() + visitor.upcast_mut::<dyn Value<'_, 'ctx, OwnedStatic<bool>, E> + '_>() { - object.visit(OwnedStatic(self.0)); + object.visit(OwnedStatic(self.0)).await; } Ok(()) - } + }) } } |