Diffstat (limited to 'src/walk/walkers/core/struct.rs')
| -rw-r--r-- | src/walk/walkers/core/struct.rs | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/walk/walkers/core/struct.rs b/src/walk/walkers/core/struct.rs index c4a9d49..561a464 100644 --- a/src/walk/walkers/core/struct.rs +++ b/src/walk/walkers/core/struct.rs @@ -1,13 +1,13 @@ use core::any::TypeId; use effectful::{ - bound::{IsSend, IsSync}, + bound::{IsSend, IsSync, Dynamic}, effective::Effective, environment::{DynBind, Environment, NativeForm}, SendSync, }; use crate::{ - any::{AnyTrait, BorrowedStatic, BorrowedStaticHrt, StaticType}, + any::{AnyTrait, BorrowedStatic, BorrowedStaticHrt, StaticType, OwnedStatic}, any_trait, hkt::Marker, never::Never, @@ -33,7 +33,7 @@ use super::{noop::NoopWalker, value::ValueWalker}; #[derive(SendSync)] pub struct StructWalker<'ctx, I: StructTypeInfo<'ctx, M, E, S = S>, S, M, E: Environment> { /// Struct value to walk. - value: &'ctx I::T, + value: Dynamic<&'ctx I::T>, /// Index of the current field to walk. index: usize, @@ -101,7 +101,7 @@ where /// Create walker from a borrow of a struct. pub fn new(value: &'ctx I::T) -> Self { Self { - value, + value: Dynamic(value), index: 0, error: None, _generics: Default::default(), @@ -178,7 +178,12 @@ any_trait! { E: Environment, I: StructTypeInfo<'ctx, M, E, S = StaticType>, M: 'ctx, - I::T: IsSync<E::NeedSend> + 'static + I::T: 'static, + Dynamic<&'ctx I::T>: DynBind<E>, + Dynamic<BorrowedStatic<'ctx, I::T>>: DynBind<E>, + for<'a, 'b> Dynamic<&'a BorrowedStatic<'b, I::T>>: DynBind<E>, + Dynamic<TypeId>: DynBind<E>, + Dynamic<OwnedStatic<TypeId>>: DynBind<E>, } impl<'ctx, I, S, M, E> Hint<'ctx, RecoverableProto<E>> for StructWalker<'ctx, I, S, M, E> @@ -538,7 +543,9 @@ impl<'ctx, I, M, E> Hint<'ctx, ValueProto<BorrowedStaticHrt<I::T>, E>> where E: Environment, I: StructTypeInfo<'ctx, M, E, S = StaticType>, - I::T: IsSync<E::NeedSend> + 'static, + I::T: 'static, + for<'a, 'b> Dynamic<&'a BorrowedStatic<'b, I::T>>: DynBind<E>, + Dynamic<&'ctx I::T>: DynBind<E>, { #[inline(always)] fn hint<'this, 'visitor, 'hint, 'e>( @@ -640,7 +647,7 @@ where let index = self.index; self.index += 1; - I::walk_field(index, self.value, visitor) + I::walk_field(index, self.value.0, visitor) .map(self, |this, result| match result { Ok(flow) => flow, Err(err) => { @@ -669,7 +676,12 @@ impl<'ctx, I, M: 'ctx, E> RecoverableScope<'ctx, E> for StructWalker<'ctx, I, St where E: Environment, I: StructTypeInfo<'ctx, M, E, S = StaticType>, - I::T: IsSync<E::NeedSend> + 'static, + I::T: 'static, + Dynamic<BorrowedStatic<'ctx, I::T>>: DynBind<E>, + for<'a, 'b> Dynamic<&'a BorrowedStatic<'b, I::T>>: DynBind<E>, + Dynamic<&'ctx I::T>: DynBind<E>, + Dynamic<TypeId>: DynBind<E>, + Dynamic<OwnedStatic<TypeId>>: DynBind<E>, { #[inline(always)] fn new_walk<'a: 'c, 'b: 'c, 'c>( @@ -690,7 +702,7 @@ where }) .cast::<()>() .if_not_finished((), |_, (this, visitor)| { - visit_value::<_, E>(visitor.cast(), BorrowedStatic(this.value)) + visit_value::<_, E>(visitor.cast(), BorrowedStatic(this.value.0)) .map((), |_, x| VisitResult::unit_skipped(x)) .cast() }) |