Diffstat (limited to 'src/walk/walkers/core/bool.rs')
| -rw-r--r-- | src/walk/walkers/core/bool.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/walk/walkers/core/bool.rs b/src/walk/walkers/core/bool.rs new file mode 100644 index 0000000..caa79d2 --- /dev/null +++ b/src/walk/walkers/core/bool.rs @@ -0,0 +1,48 @@ +use crate::{ + any::static_wrapper::OwnedStatic, + protocol::{visitor::Value, Effect}, +}; +use core::{mem::MaybeUninit, ops::ControlFlow}; + +use crate::{ + any_trait, + protocol::{ + visitor::{RequestHint, Sequence, SequenceScope, Status}, + walker::{Hint, HintMeta}, + ControlFlowFor, SyncEffect, Visitor, + }, +}; + +impl<'ctx> crate::Walk<'ctx> for bool { + type Walker = Walker; +} + +pub struct Walker(bool); + +impl<'ctx> From<bool> for Walker { + fn from(value: bool) -> Self { + Self(value) + } +} + +impl<'ctx> crate::Walker<'ctx> for Walker { + type Effect = SyncEffect; + + type Error = (); + + type Output = (); + + #[inline] + fn walk<'a>( + self, + visitor: &'a mut Visitor<'a, 'ctx>, + ) -> ControlFlowFor<'a, Self::Effect, Self::Output, Self::Error> { + SyncEffect::wrap(async { + if let Some(object) = visitor.upcast_mut::<dyn Value<'_, OwnedStatic<bool>> + '_>() { + object.visit(OwnedStatic(self.0)).await; + } + + ControlFlow::Continue(()) + }) + } +} |