Diffstat (limited to 'src/build/builders/core/struct.rs')
| -rw-r--r-- | src/build/builders/core/struct.rs | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/src/build/builders/core/struct.rs b/src/build/builders/core/struct.rs index 1b5c00a..7e8d854 100644 --- a/src/build/builders/core/struct.rs +++ b/src/build/builders/core/struct.rs @@ -3,7 +3,7 @@ use core::{marker::PhantomData, ops::ControlFlow}; use crate::{ any::{OwnedStatic, TempBorrowedStatic, TempBorrowedStaticHrt, TypeName}, any_trait, - effect::{Adapters, Effect, ObjSafe}, + effect::{Effect, Effective, ErasedEffective}, hkt::Marker, protocol::{ visitor::{ @@ -42,9 +42,11 @@ pub trait StructTypeInfo<'ctx, M, E: Effect>: 'static { type T: Send + Sync; - fn new_builders<'a>(seed: Self::Seed) -> ObjSafe<'a, Self::Builders, E>; + fn new_builders<'a>(seed: Self::Seed) -> ErasedEffective<'a, Self::Builders, E>; - fn from_builders<'a>(builders: Self::Builders) -> ObjSafe<'a, Result<Self::T, Self::Error>, E>; + fn from_builders<'a>( + builders: Self::Builders, + ) -> ErasedEffective<'a, Result<Self::T, Self::Error>, E>; fn as_visitor<'a>( marker: Self::FieldMarker, @@ -86,7 +88,7 @@ where E: Effect, { #[inline(always)] - fn from_seed<'a>(seed: Self::Seed) -> ObjSafe<'a, Self, E> + fn from_seed<'a>(seed: Self::Seed) -> ErasedEffective<'a, Self, E> where Self: 'a, { @@ -99,10 +101,10 @@ where _generics: Default::default(), } }) - .into() + .into_erased() } - fn build<'a>(self) -> ObjSafe<'a, Result<Self::Value, Self::Error>, E> + fn build<'a>(self) -> ErasedEffective<'a, Result<Self::Value, Self::Error>, E> where Self: 'a, { @@ -111,7 +113,7 @@ where Ok(value) => Ok(value), Err(err) => Err(StructError { error: err }), }) - .into() + .into_erased() } fn as_visitor(&mut self) -> DynVisitor<'_, 'ctx> { @@ -134,24 +136,23 @@ where E: Effect, { #[inline(always)] - fn visit<'a>( + fn visit<'a: 'c, 'b: 'c, 'c>( &'a mut self, _kind: tags::Map, - walker: DynWalkerObjSafe<'a, 'ctx, E>, - ) -> ObjSafe<'a, VisitResult<DynWalkerObjSafe<'a, 'ctx, E>>, E> { + walker: DynWalkerObjSafe<'b, 'ctx, E>, + ) -> ErasedEffective<'c, VisitResult<DynWalkerObjSafe<'b, 'ctx, E>>, E> { // This signals to go into map mode for the sequence. self.mode = StructMode::Map; - E::with(NoopVisitor::new(), |noop, _| { - ( + E::ready(NoopVisitor::new()) + .as_ctx(|noop| { walker .walk(DynVisitor(noop)) .map(|x| x.to_continue().into()) - .into(), - PhantomData, - ) - }) - .into() + .into_erased() + }) + .map(|(_, value)| value) + .into_erased() } } @@ -165,7 +166,7 @@ where fn visit<'a>( &'a mut self, scope: DynSequenceScope<'a, 'ctx, E>, - ) -> ObjSafe<'a, VisitResult<DynSequenceScope<'a, 'ctx, E>>, E> { + ) -> ErasedEffective<'a, VisitResult<DynSequenceScope<'a, 'ctx, E>>, E> { match self.mode { StructMode::Tuple => { E::ready((self, scope, 0)) @@ -192,12 +193,14 @@ where ControlFlow::Break(VisitResult::Control(Flow::Done)) } }) - .into() + .into_erased() } else { - E::ready(ControlFlow::Break(VisitResult::Control(Flow::Done))).into() + E::ready(ControlFlow::Break(VisitResult::Control(Flow::Done))) + .into_erased() } }) - .into() + .map(|(_, value)| value) + .into_erased() } StructMode::Map => { todo!() @@ -268,17 +271,17 @@ any_trait! { I: StructTypeInfo<'ctx, M, E>, } -impl<'b, 'ctx, I, M, E> Tag<'ctx, tags::Key, E> for FieldVisitor<'b, 'ctx, I, M, E> +impl<'d, 'ctx, I, M, E> Tag<'ctx, tags::Key, E> for FieldVisitor<'d, 'ctx, I, M, E> where E: Effect, I: StructTypeInfo<'ctx, M, E>, { #[inline(always)] - fn visit<'a>( + fn visit<'a: 'c, 'b: 'c, 'c>( &'a mut self, _key: tags::Key, - walker: DynWalkerObjSafe<'a, 'ctx, E>, - ) -> ObjSafe<'a, VisitResult<DynWalkerObjSafe<'a, 'ctx, E>>, E> { + walker: DynWalkerObjSafe<'b, 'ctx, E>, + ) -> ErasedEffective<'c, VisitResult<DynWalkerObjSafe<'b, 'ctx, E>>, E> { todo!() // E::wrap(async { // let mut visitor = NameVisitor::<I, M, E> { @@ -320,14 +323,14 @@ where fn visit<'a>( &'a mut self, OwnedStatic(index): TypeName::T<'a, 'ctx, OwnedStatic<usize>>, - ) -> ObjSafe<'a, VisitResult<TypeName::T<'a, 'ctx, OwnedStatic<usize>>>, E> + ) -> ErasedEffective<'a, VisitResult<TypeName::T<'a, 'ctx, OwnedStatic<usize>>>, E> where TypeName::T<'a, 'ctx, OwnedStatic<usize>>: Send + Sized, 'ctx: 'a, { self.field_marker = I::marker_from_index(index); - E::ready(VisitResult::Control(Flow::Done)).into() + E::ready(VisitResult::Control(Flow::Done)).into_erased() } } @@ -340,14 +343,14 @@ where fn visit<'a>( &'a mut self, TempBorrowedStatic(name): TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>>, - ) -> ObjSafe<'a, VisitResult<TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>>>, E> + ) -> ErasedEffective<'a, VisitResult<TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>>>, E> where TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>>: Send + Sized, 'ctx: 'a, { self.field_marker = I::marker_from_name(name); - E::ready(VisitResult::Control(Flow::Done)).into() + E::ready(VisitResult::Control(Flow::Done)).into_erased() } } @@ -360,13 +363,13 @@ where fn visit<'a>( &'a mut self, OwnedStatic(name): TypeName::T<'a, 'ctx, OwnedStatic<&'static str>>, - ) -> ObjSafe<'a, VisitResult<TypeName::T<'a, 'ctx, OwnedStatic<&'static str>>>, E> + ) -> ErasedEffective<'a, VisitResult<TypeName::T<'a, 'ctx, OwnedStatic<&'static str>>>, E> where TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>>: Send + Sized, 'ctx: 'a, { self.field_marker = I::marker_from_name(name); - E::ready(VisitResult::Control(Flow::Done)).into() + E::ready(VisitResult::Control(Flow::Done)).into_erased() } } |