use crate::{any::static_wrapper::OwnedStatic, protocol::visitor::value::Value};
use core::{marker::PhantomData, mem::MaybeUninit, ops::ControlFlow};
use crate::{
any_trait,
effect::{Effect, Future},
protocol::{
walker::hint::{Hint, HintMeta},
Visitor,
},
};
impl<'ctx> crate::Walk<'ctx> for bool {
type Walker<E: Effect<'ctx>> = Walker<E>;
fn into_walker<E: Effect<'ctx>>(self) -> Self::Walker<E> {
Walker(self, PhantomData)
}
}
pub struct Walker<E>(bool, PhantomData<fn() -> E>);
impl crate::WalkerTypes for bool {
type Error = ();
type Output = ();
}
impl<E> crate::WalkerTypes 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>,
) -> 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<'_, 'ctx, OwnedStatic<bool>, Effect = E> + '_>()
{
object.visit(OwnedStatic(self.0)).await;
}
Ok(())
})
}
}