Diffstat (limited to 'src/build/builders/core/struct.rs')
| -rw-r--r-- | src/build/builders/core/struct.rs | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/src/build/builders/core/struct.rs b/src/build/builders/core/struct.rs index 2da2879..1b5c00a 100644 --- a/src/build/builders/core/struct.rs +++ b/src/build/builders/core/struct.rs @@ -1,3 +1,5 @@ +use core::{marker::PhantomData, ops::ControlFlow}; + use crate::{ any::{OwnedStatic, TempBorrowedStatic, TempBorrowedStaticHrt, TypeName}, any_trait, @@ -83,6 +85,7 @@ where I: StructTypeInfo<'ctx, M, E>, E: Effect, { + #[inline(always)] fn from_seed<'a>(seed: Self::Seed) -> ObjSafe<'a, Self, E> where Self: 'a, @@ -139,11 +142,14 @@ where // This signals to go into map mode for the sequence. self.mode = StructMode::Map; - E::with(NoopVisitor::new(), |noop| { - walker - .walk(DynVisitor(noop)) - .map(|x| x.to_continue().into()) - .into() + E::with(NoopVisitor::new(), |noop, _| { + ( + walker + .walk(DynVisitor(noop)) + .map(|x| x.to_continue().into()) + .into(), + PhantomData, + ) }) .into() } @@ -160,7 +166,44 @@ where &'a mut self, scope: DynSequenceScope<'a, 'ctx, E>, ) -> ObjSafe<'a, VisitResult<DynSequenceScope<'a, 'ctx, E>>, E> { - todo!() + match self.mode { + StructMode::Tuple => { + E::ready((self, scope, 0)) + .r#loop(|(this, scope, index)| { + if let Some(marker) = I::marker_from_index(*index) { + // Select the visitor for this field. + let visitor = I::as_visitor(marker, &mut this.builders); + + // For rust analyzer. + let scope: &mut DynSequenceScope<'_, '_, E> = scope; + + scope + .next(visitor) + .map(|flow| match flow { + Flow::Continue => { + *index += 1; + + ControlFlow::Continue(()) + } + Flow::Err => { + ControlFlow::Break(VisitResult::Control(Flow::Err)) + } + Flow::Done => { + ControlFlow::Break(VisitResult::Control(Flow::Done)) + } + }) + .into() + } else { + E::ready(ControlFlow::Break(VisitResult::Control(Flow::Done))).into() + } + }) + .into() + } + StructMode::Map => { + todo!() + } + } + // match self.mode { // StructMode::Tuple => E::wrap(async { // let mut index = 0; |