Diffstat (limited to 'src/protocol/walker/hint.rs')
| -rw-r--r-- | src/protocol/walker/hint.rs | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/protocol/walker/hint.rs b/src/protocol/walker/hint.rs index dc2a37e..9b86ded 100644 --- a/src/protocol/walker/hint.rs +++ b/src/protocol/walker/hint.rs @@ -7,10 +7,7 @@ use core::ops::{Deref, DerefMut}; use effectful::{ - effective::Effective, - environment::{DynBind, EnvConfig, Environment, InEnvironment, NativeForm}, - higher_ranked::{Hrt, WithLt}, - SendSync, + effective::{Canonical, Effective}, environment::{Environment, InEnvironment}, higher_ranked::{Hrt, WithLt}, DynBind, SendSync }; use crate::{ @@ -38,11 +35,11 @@ pub trait Hint<'ctx, Protocol: ?Sized + HintMeta>: DynBind<Protocol::Env> { /// Hint to the walker to use the `P` protocol. /// /// This should only be called once per [`RequestHint`]. - fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>( + fn hint<'this: 'e, 'visitor: 'e, 'lt: 'e, 'hint: 'e, 'e>( &'this mut self, - visitor: DynVisitorWith<'visitor, 'ctx, Protocol>, + visitor: DynVisitorWith<'visitor, 'lt, 'ctx, Protocol>, hint: WithLt<'hint, Protocol::Hint>, - ) -> NativeForm<'e, VisitResult, Protocol::Env> + ) -> Canonical<'e, VisitResult, Protocol::Env> where 'ctx: 'this + 'visitor + 'hint; @@ -50,21 +47,21 @@ pub trait Hint<'ctx, Protocol: ?Sized + HintMeta>: DynBind<Protocol::Env> { fn known<'a>( &'a mut self, hint: &'a WithLt<'a, Protocol::Hint>, - ) -> NativeForm<'a, Result<WithLt<'a, Protocol::Known>, ()>, Protocol::Env> + ) -> Canonical<'a, Result<WithLt<'a, Protocol::Known>, ()>, Protocol::Env> where WithLt<'a, Protocol::Known>: DynBind<Protocol::Env>; } #[derive(SendSync)] -pub struct DynVisitorWith<'temp, 'ctx, Protocol: ?Sized + HintMeta> { - visitor: DynVisitor<'temp, 'ctx, Protocol::Env>, +pub struct DynVisitorWith<'temp, 'lt, 'ctx, Protocol: ?Sized + HintMeta> { + visitor: DynVisitor<'temp, 'lt, 'ctx, Protocol::Env>, _marker: Marker<Protocol>, } -impl<'temp, 'ctx: 'temp, Protocol: ?Sized + HintMeta> DynVisitorWith<'temp, 'ctx, Protocol> { +impl<'temp, 'lt: 'temp, 'ctx: 'lt, Protocol: ?Sized + HintMeta> DynVisitorWith<'temp, 'lt, 'ctx, Protocol> { pub fn new<T>(visitor: &'temp mut T) -> Self where - T: AnyTraitDynBind<'temp, 'ctx, Protocol::Env>, + T: AnyTraitDynBind<'lt, 'ctx, Protocol::Env>, { Self { visitor: DynVisitor(visitor), @@ -72,26 +69,26 @@ impl<'temp, 'ctx: 'temp, Protocol: ?Sized + HintMeta> DynVisitorWith<'temp, 'ctx } } - pub fn as_known(&mut self) -> &mut type_name::Lowered<'temp, 'ctx, Protocol> { + pub fn as_known(&mut self) -> &mut type_name::Lowered<'lt, 'ctx, Protocol> { self.visitor - .upcast_mut::<type_name::Lowered<'temp, 'ctx, Protocol>>() + .upcast_mut::<type_name::Lowered<'lt, 'ctx, Protocol>>() .unwrap() } - pub fn into_inner(self) -> DynVisitor<'temp, 'ctx, Protocol::Env> { + pub fn into_inner(self) -> DynVisitor<'temp, 'lt, 'ctx, Protocol::Env> { self.visitor } } -impl<'temp, 'ctx, Protocol: ?Sized + HintMeta> Deref for DynVisitorWith<'temp, 'ctx, Protocol> { - type Target = DynVisitor<'temp, 'ctx, Protocol::Env>; +impl<'temp, 'lt, 'ctx, Protocol: ?Sized + HintMeta> Deref for DynVisitorWith<'temp, 'lt, 'ctx, Protocol> { + type Target = DynVisitor<'temp, 'lt, 'ctx, Protocol::Env>; fn deref(&self) -> &Self::Target { &self.visitor } } -impl<'temp, 'ctx, Protocol: ?Sized + HintMeta> DerefMut for DynVisitorWith<'temp, 'ctx, Protocol> { +impl<'temp, 'lt, 'ctx, Protocol: ?Sized + HintMeta> DerefMut for DynVisitorWith<'temp, 'lt, 'ctx, Protocol> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.visitor } @@ -121,23 +118,24 @@ pub fn hint_protocol< 'walker: 'e, 'visitor: 'e, 'hint: 'e, + 'lt: 'e, 'e, Protocol: ?Sized + type_name::WithLt<'static, 'static>, E, T, >( - walker: DynWalker<'walker, 'ctx, E>, + walker: DynWalker<'walker, 'lt, 'ctx, E>, visitor: &'visitor mut T, hint: WithLt<'hint, <type_name::Raised<'static, 'static, Protocol> as HintMeta>::Hint>, -) -> NativeForm<'e, VisitResult<()>, E> +) -> Canonical<'e, VisitResult<()>, E> where E: Environment, - T: AnyTrait<'ctx> + DynBind<E>, + T: AnyTrait<'lt, 'ctx> + DynBind<E>, type_name::Raised<'static, 'static, Protocol>: HintMeta<Env = E>, { if let Some(object) = walker .0 - .cast_mut2() + .cast_mut() .upcast_mut::<dyn Hint<'ctx, type_name::Raised<'static, 'static, Protocol>> + '_>() { object |