Diffstat (limited to 'src/build/builders/core/bool.rs')
| -rw-r--r-- | src/build/builders/core/bool.rs | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/src/build/builders/core/bool.rs b/src/build/builders/core/bool.rs index 3becdae..64f6876 100644 --- a/src/build/builders/core/bool.rs +++ b/src/build/builders/core/bool.rs @@ -3,16 +3,12 @@ use core::{marker::PhantomData, ops::ControlFlow}; use crate::{ any::static_wrapper::OwnedStatic, any_trait, - effect::{AsObj, AsyncEffect, Effect, SyncEffect, Yield}, - protocol::visitor::Value, - AsVisitor, + effect::{Effect, Future}, + protocol::{visitor::value::Value, Visitor}, }; -impl<'ctx, E: Effect<'ctx, ControlFlow<(), ()>>> crate::Build<'ctx, E> for bool -where - Builder<E>: AsVisitor<'ctx, E>, -{ - type Builder = Builder<E>; +impl<'ctx> crate::Build<'ctx> for bool { + type Builder<E: Effect<'ctx>> = Builder<E>; } #[derive(Debug)] @@ -22,56 +18,58 @@ pub enum Error { pub struct Builder<E>(Option<bool>, PhantomData<fn() -> E>); -impl<'ctx, E: Effect<'ctx, ControlFlow<(), ()>>> crate::Builder<'ctx, E> for Builder<E> -where - Self: AsVisitor<'ctx, E>, -{ +impl<'ctx> crate::BuilderTypes<'ctx> for bool { + type Seed = (); + type Error = Error; type Value = bool; +} + +impl<'ctx, E: Effect<'ctx>> crate::BuilderTypes<'ctx> for Builder<E> { + type Error = Error; + + type Value = bool; + + type Seed = (); +} + +impl<'ctx, E: Effect<'ctx>> crate::Builder<'ctx> for Builder<E> { + type Effect = E; #[inline] - fn build<'a>(self) -> Result<Self::Value, Self::Error> + fn build<'a>(self) -> Future<'a, 'ctx, Result<Self::Value, Self::Error>, E> where Self: 'a, { - self.0.ok_or(Error::Incomplete) + E::wrap(core::future::ready(self.0.ok_or(Error::Incomplete))) } - type Seed = (); - - fn from_seed(_seed: Self::Seed) -> Self { - Self(None, PhantomData) - } - - type Effect = SyncEffect; -} - -impl<'ctx> AsVisitor<'ctx, SyncEffect> for Builder<SyncEffect> { - fn as_visitor(&mut self) -> crate::protocol::Visitor<'_, 'ctx, SyncEffect> { - self + fn from_seed<'a>(_seed: Self::Seed) -> Future<'a, 'ctx, Self, E> + where + Self: 'a, + { + E::wrap(core::future::ready(Self(None, PhantomData))) } -} -impl<'ctx> AsVisitor<'ctx, AsyncEffect> for Builder<AsyncEffect> { - fn as_visitor(&mut self) -> crate::protocol::Visitor<'_, 'ctx, AsyncEffect> { + fn as_visitor(&mut self) -> Visitor<'_, 'ctx> { self } } any_trait! { impl['a, 'ctx, E] Builder<E> = [ - dyn Value<'a, 'ctx, OwnedStatic<bool>, SyncEffect> + 'a, - ] + dyn Value<'a, 'ctx, OwnedStatic<bool>, E> + 'a, + ] where E: Effect<'ctx> } -impl<'a, 'ctx: 'a, E> Value<'a, 'ctx, OwnedStatic<bool>, SyncEffect> for Builder<E> { +impl<'a, 'ctx: 'a, E: Effect<'ctx>> Value<'a, 'ctx, OwnedStatic<bool>, E> for Builder<E> { #[inline] fn visit( &'a mut self, OwnedStatic(value): OwnedStatic<bool>, - ) -> Yield<'a, 'ctx, ControlFlow<(), ()>, SyncEffect> { + ) -> Future<'a, 'ctx, ControlFlow<(), ()>, E> { self.0 = Some(value); - ControlFlow::Continue(()) + E::wrap(core::future::ready(ControlFlow::Continue(()))) } } |