1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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(())
        })
    }
}