Diffstat (limited to 'src/walk/walkers/core/value.rs')
| -rw-r--r-- | src/walk/walkers/core/value.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/walk/walkers/core/value.rs b/src/walk/walkers/core/value.rs index 252ca35..5ed43e0 100644 --- a/src/walk/walkers/core/value.rs +++ b/src/walk/walkers/core/value.rs @@ -1,6 +1,7 @@ +use effectful::{bound::IsSync, environment::{DynBind, Environment, NativeForm}, forward_send_sync}; + use crate::{ any::{BorrowedStatic, OwnedStatic, TempBorrowedStatic}, - effect::{Effect, EffectExt as _, Effective, EffectiveExt as _, ErasedEffective}, never::Never, protocol::{ visitor::{visit_value, EffectiveVisitExt as _, VisitResult}, @@ -15,6 +16,8 @@ use crate::{ #[derive(Debug)] pub struct ValueWalker<T>(T); +forward_send_sync!({T} {} ValueWalker<T>); + impl<T> ValueWalker<T> { /// Create walker from a value. #[inline(always)] @@ -37,7 +40,10 @@ impl<T: Copy> From<&T> for ValueWalker<T> { } } -impl<'ctx, T: Send + Sync + 'static, E: Effect> crate::Walker<'ctx, E> for ValueWalker<T> { +impl<'ctx, T: 'static, E: Environment> crate::Walker<'ctx, E> for ValueWalker<T> +where + T: DynBind<E> +{ type Error = Never; type Output = (); @@ -45,8 +51,8 @@ impl<'ctx, T: Send + Sync + 'static, E: Effect> crate::Walker<'ctx, E> for Value #[inline(always)] fn walk<'b: 'c, 'c>( self, - visitor: DynVisitor<'b, 'ctx>, - ) -> ErasedEffective<'c, Result<Self::Output, Self::Error>, E> { + visitor: DynVisitor<'b, 'ctx, E>, + ) -> NativeForm<'c, Result<Self::Output, Self::Error>, E> { // Attempt to visit using the value protocol. visit_value::<_, E>(visitor, OwnedStatic(self.0)).map(|_| Ok(())) } @@ -57,6 +63,8 @@ impl<'ctx, T: Send + Sync + 'static, E: Effect> crate::Walker<'ctx, E> for Value /// This walker supports values borrowed for `'ctx` or longer. pub struct BorrowWalker<'ctx, T: ?Sized>(&'ctx T); +forward_send_sync!({} {T: (?Sized + 'ctx)} {{'ctx}} BorrowWalker<'ctx, T>); + impl<'ctx, T: ?Sized> BorrowWalker<'ctx, T> { /// Create walker from a value. #[inline(always)] @@ -65,8 +73,10 @@ impl<'ctx, T: ?Sized> BorrowWalker<'ctx, T> { } } -impl<'ctx, T: ?Sized + Send + Sync + 'static, E: Effect> crate::Walker<'ctx, E> +impl<'ctx, T: ?Sized + DynBind<E> + 'static, E: Environment> crate::Walker<'ctx, E> for BorrowWalker<'ctx, T> +where + T: IsSync<E::NeedSend> { type Error = Never; @@ -75,8 +85,8 @@ impl<'ctx, T: ?Sized + Send + Sync + 'static, E: Effect> crate::Walker<'ctx, E> #[inline(always)] fn walk<'b: 'c, 'c>( self, - visitor: DynVisitor<'b, 'ctx>, - ) -> ErasedEffective<'c, Result<Self::Output, Self::Error>, E> { + visitor: DynVisitor<'b, 'ctx, E>, + ) -> NativeForm<'c, Result<Self::Output, Self::Error>, E> { // Attempt to visit using the value protocol. E::as_ctx((self, visitor), |(this, visitor)| { visit_value::<_, E>(visitor.cast(), BorrowedStatic(this.0)) |