Diffstat (limited to 'src/build/builders/core/struct.rs')
| -rw-r--r-- | src/build/builders/core/struct.rs | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/src/build/builders/core/struct.rs b/src/build/builders/core/struct.rs index 6e304f9..d884f96 100644 --- a/src/build/builders/core/struct.rs +++ b/src/build/builders/core/struct.rs @@ -1,4 +1,5 @@ use core::fmt::{Debug, Display}; +use crate::hkt::BorrowsCtx; use effectful::{ bound::Dynamic, @@ -105,10 +106,12 @@ pub trait StructTypeInfo<'lt, 'ctx, Mode: 'ctx, E: Environment>: 'lt { /// Get the visitor for a field. /// /// This is how [`StructBuilder`] picks a field builder to use. - fn as_visitor<'a>( + fn as_visitor<'a, 'b>( marker: Self::FieldMarker, builders: &'a mut Self::Builders, - ) -> DynVisitor<'a, 'lt, 'ctx, E>; + ) -> DynVisitor<'a, 'b, 'ctx, E> + where + 'lt: 'b; /// Get a field marker from the index of the field. /// @@ -326,7 +329,7 @@ where // Mode: 'ctx, // } -impl<'lt, 'ctx, Info, Mode: 'ctx, E> RequestHint<'ctx, E> for StructBuilder<'lt, 'ctx, Info, Mode, E> +impl<'lt, 'ctx: 'lt, Info, Mode: 'ctx, E> RequestHint<'ctx, E> for StructBuilder<'lt, 'ctx, Info, Mode, E> where Self: DynBind<E>, Info: StructTypeInfo<'lt, 'ctx, Mode, E>, @@ -346,7 +349,7 @@ where walker: DynWalker<'walker, 'd, 'ctx, E>, ) -> Canonical<'e, VisitResult, E> where - 'ctx: 'this + 'walker, + 'ctx: 'this + 'walker + 'd, { E::value((self, walker)) .update_map((), |_, (this, walker)| { @@ -432,11 +435,14 @@ where Info: StructTypeInfo<'lt, 'ctx, Mode, E>, E: Environment, { - fn visit<'this: 'e, 'walker: 'e, 'e>( + fn visit<'this: 'e, 'walker: 'e, 'd: 'e, 'e>( &'this mut self, _kind: tags::Struct, - walker: DynWalkerObjSafe<'walker, 'ctx, E>, - ) -> Canonical<'e, VisitResult, E> { + walker: DynWalkerObjSafe<'walker, 'd, 'ctx, E>, + ) -> Canonical<'e, VisitResult, E> + where + 'ctx: 'd + { // If this protocol is used then we need to create the builders. E::value(self) .update_map((), |_, this| this.make_builders().cast()) @@ -462,11 +468,14 @@ where Info: StructTypeInfo<'lt, 'ctx, Mode, E>, E: Environment, { - fn visit<'this: 'e, 'walker: 'e, 'e>( + fn visit<'this: 'e, 'walker: 'e, 'd: 'e, 'e>( &'this mut self, _kind: tags::Map, - walker: DynWalkerObjSafe<'walker, 'ctx, E>, - ) -> Canonical<'e, VisitResult, E> { + walker: DynWalkerObjSafe<'walker, 'd, 'ctx, E>, + ) -> Canonical<'e, VisitResult, E> + where + 'ctx: 'd + { // If this protocol is used then we need to create the builders. E::value(self) .update_map((), |_, this| this.make_builders().cast()) @@ -489,7 +498,7 @@ where /// /// If the [`tags::Struct`] or [`tags::Map`] tags are used then this will expect /// a sequence of key value pairs. Where the key is the field name. -impl<'lt, 'ctx, Info, Mode: 'ctx, E> Sequence<'ctx, E> for StructBuilder<'lt, 'ctx, Info, Mode, E> +impl<'lt, 'ctx: 'lt, Info, Mode: 'ctx, E> Sequence<'ctx, E> for StructBuilder<'lt, 'ctx, Info, Mode, E> where Self: DynBind<E>, Info: StructTypeInfo<'lt, 'ctx, Mode, E>, @@ -549,6 +558,7 @@ where builders, marker: None, _marker: Default::default(), + _m: BorrowsCtx::NEW }; // Loop through all the elements in the sequence. @@ -582,6 +592,7 @@ struct FieldVisitor<'a, 'lt, 'ctx, I: StructTypeInfo<'lt, 'ctx, M, E>, M, E: Env builders: &'a mut I::Builders, marker: Option<I::FieldMarker>, _marker: Marker<E>, + _m: BorrowsCtx<'lt, 'ctx> } impl<'e, 'lt: 'e, 'ctx: 'lt, I: StructTypeInfo<'lt, 'ctx, M, E>, M: 'lt, E: Environment> AnyTrait<'e, 'ctx> @@ -635,7 +646,7 @@ where // for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>, // } -impl<'d, 'lt, 'ctx, I, M, E> Tag<'ctx, tags::Key, E> for FieldVisitor<'d, 'lt, 'ctx, I, M, E> +impl<'d, 'lt, 'ctx: 'lt, I, M, E> Tag<'ctx, tags::Key, E> for FieldVisitor<'d, 'lt, 'ctx, I, M, E> where E: Environment, I: StructTypeInfo<'lt, 'ctx, M, E>, @@ -644,14 +655,18 @@ where Dynamic<OwnedStatic<String>>: DynBind<E>, for<'a> Dynamic<TempBorrowedStatic<'a, str>>: DynBind<E>, { - fn visit<'a: 'c, 'b: 'c, 'c>( + fn visit<'a: 'c, 'b: 'c, 'e: 'c, 'c>( &'a mut self, _key: tags::Key, - walker: DynWalkerObjSafe<'b, 'ctx, E>, - ) -> Canonical<'c, VisitResult, E> { + walker: DynWalkerObjSafe<'b, 'e, 'ctx, E>, + ) -> Canonical<'c, VisitResult, E> + where + 'ctx: 'e + { let visitor = NameVisitor::<I, M, E> { field_marker: None, _marker: Default::default(), + _m: BorrowsCtx::NEW, }; E::value((self, visitor, walker)) @@ -670,6 +685,7 @@ where struct NameVisitor<'lt, 'ctx, I: StructTypeInfo<'lt, 'ctx, M, E>, M, E: Environment> { field_marker: Option<I::FieldMarker>, _marker: Marker<E>, + _m: BorrowsCtx<'lt, 'ctx>, } impl<'lt, 'ctx: 'lt, I: StructTypeInfo<'lt, 'ctx, M, E>, M: 'lt, E: Environment> AnyTrait<'lt, 'ctx> |