Diffstat (limited to 'src/protocol/walker/hint.rs')
| -rw-r--r-- | src/protocol/walker/hint.rs | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/protocol/walker/hint.rs b/src/protocol/walker/hint.rs index 50cd71d..2084b5b 100644 --- a/src/protocol/walker/hint.rs +++ b/src/protocol/walker/hint.rs @@ -6,7 +6,12 @@ use core::ops::{Deref, DerefMut}; -use effectful::environment::{DynBind, EnvConfig, Environment, NativeForm}; +use effectful::{ + bound::{IsSend, IsSync}, + effective::Effective, + environment::{DynBind, EnvConfig, Environment, NativeForm}, + higher_ranked::Mut, +}; use crate::{ any::{AnyTrait, TypeName}, @@ -23,15 +28,24 @@ pub mod Meta { type T: ?Sized + LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx (), Higher = Self>; } - pub trait MemberType<E: EnvConfig>: for<'a, 'ctx> MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> {} + pub trait MemberType<E: EnvConfig>: + for<'a, 'ctx> MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> + { + } - impl<T: ?Sized, E: EnvConfig> MemberType<E> for T where T: for<'a, 'ctx> MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> {} + impl<T: ?Sized, E: EnvConfig> MemberType<E> for T where + T: for<'a, 'ctx> MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> + { + } pub trait LowerTypeWithBound<'a, 'ctx: 'a, E: EnvConfig, B>: 'a + DynBind<E> + Sized { type Higher: ?Sized + MemberTypeForLt<'a, 'ctx, E, &'a &'ctx (), T = Self>; } - pub trait LowerType<'a, 'ctx: 'a, E: EnvConfig>: LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> {} + pub trait LowerType<'a, 'ctx: 'a, E: EnvConfig>: + LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> + { + } impl<'a, 'ctx: 'a, E: EnvConfig, T: ?Sized> LowerType<'a, 'ctx, E> for T where T: LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> @@ -67,8 +81,10 @@ pub trait HintMeta: TypeName::MemberType<Self::Effect> + 'static { type Effect: Environment; } -pub type MetaKnown<'a, 'ctx, Protocol> = Meta::T<'a, 'ctx, <Protocol as HintMeta>::Known, <Protocol as HintMeta>::Effect>; -pub type MetaHint<'a, 'ctx, Protocol> = Meta::T<'a, 'ctx, <Protocol as HintMeta>::Hint, <Protocol as HintMeta>::Effect>; +pub type MetaKnown<'a, 'ctx, Protocol> = + Meta::T<'a, 'ctx, <Protocol as HintMeta>::Known, <Protocol as HintMeta>::Effect>; +pub type MetaHint<'a, 'ctx, Protocol> = + Meta::T<'a, 'ctx, <Protocol as HintMeta>::Hint, <Protocol as HintMeta>::Effect>; /// Object implementing the [`Hint`] protocol. pub trait Hint<'ctx, Protocol: ?Sized + HintMeta>: DynBind<Protocol::Effect> { @@ -95,6 +111,16 @@ pub struct DynVisitorWith<'temp, 'ctx, Protocol: ?Sized + HintMeta> { _marker: Marker<Protocol>, } +unsafe impl<'a, 'ctx, P: HintMeta> IsSend<<P::Effect as EnvConfig>::NeedSend> + for DynVisitorWith<'a, 'ctx, P> +{ +} + +unsafe impl<'a, 'ctx, P: HintMeta> IsSync<<P::Effect as EnvConfig>::NeedSync> + for DynVisitorWith<'a, 'ctx, P> +{ +} + pub trait HasProtocol<Protocol: ?Sized> {} impl<'temp, 'ctx: 'temp, Protocol: ?Sized + HintMeta> DynVisitorWith<'temp, 'ctx, Protocol> { @@ -141,7 +167,8 @@ where type T = dyn Hint<'ctx, Protocol> + 'a; } -impl<'a, 'ctx, Protocol: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, Protocol::Effect, &'a &'ctx ()> +impl<'a, 'ctx, Protocol: ?Sized> + TypeName::LowerTypeWithBound<'a, 'ctx, Protocol::Effect, &'a &'ctx ()> for dyn Hint<'ctx, Protocol> + 'a where Protocol: HintMeta, @@ -168,8 +195,9 @@ where if let Some(object) = walker.0.upcast_mut::<HintProto<Protocol>>() { object .hint(DynVisitorWith::new(visitor), hint) - .map(Into::into) + .map((), |_, x| Into::into(x)) + .cast() } else { - VisitResult::Skipped(()).ready() + Protocol::Effect::value(VisitResult::Skipped(())).cast() } } |