Diffstat (limited to 'src/protocol/walker/hint.rs')
| -rw-r--r-- | src/protocol/walker/hint.rs | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/protocol/walker/hint.rs b/src/protocol/walker/hint.rs index 06c8794..ce73b7e 100644 --- a/src/protocol/walker/hint.rs +++ b/src/protocol/walker/hint.rs @@ -7,42 +7,42 @@ use crate::{ any::{TypeName, TypeNameable}, nameable, - protocol::{ControlFlowFor, Effect, SyncEffect, Visitor}, + protocol::{ControlFlowFor, Effect, SyncEffect, Visitor, any_t}, }; /// Meta information for the hint. /// /// This gives the visitor more information to work from when selecting a hint. -pub trait HintMeta<'a, 'ctx: 'a> { +pub trait HintMeta<'ctx> { /// Information known by the walker. /// /// This should be information easy to get without changing the state of the walker /// in an irreversible way. - type Known; + type KnownHkt: any_t::Hkt<'ctx>; /// Extra information the visitor can give to the walker about what it is expecting. type Hint; } /// Object implementing the [`Hint`] protocol. -pub trait Hint<'ctx, Protocol: ?Sized + for<'a> HintMeta<'a, 'ctx>, E = SyncEffect> +pub trait Hint<'ctx, Protocol: ?Sized + HintMeta<'ctx>, E = SyncEffect> where - E: Effect<'ctx> + Effect<'ctx, <Protocol as HintMeta<'a, 'ctx>>::Known> + E: Effect<'ctx> + for<'a> Effect<'ctx, <<Protocol as HintMeta<'ctx>>::KnownHkt as any_t::ForLt<'a, 'ctx, crate::hkt::Bound<'a, 'ctx>>>::T> { /// Hint to the walker to use the `P` protocol. /// /// This should only be called once per [`RequestHint`]. fn hint<'a>( &'a mut self, - visitor: &'a mut Visitor<'a, 'ctx, E>, - hint: <Protocol as HintMeta<'a, 'ctx>>::Hint, + visitor: Visitor<'a, 'ctx, E>, + hint: <Protocol as HintMeta<'ctx>>::Hint, ) -> ControlFlowFor<'a, 'ctx, E>; /// Ask the walker for information about it's support of the protocol. fn known<'a>( &'a mut self, - hint: &'a <Protocol as HintMeta<'a, 'ctx>>::Hint, - ) -> ControlFlowFor<'a, 'ctx, E, <Protocol as HintMeta<'a, 'ctx>>::Known> + hint: &'a <Protocol as HintMeta<'ctx>>::Hint, + ) -> ControlFlowFor<'a, 'ctx, E, any_t::T<'a, 'ctx, <Protocol as HintMeta<'ctx>>::KnownHkt>> where 'ctx: 'a; } @@ -68,6 +68,7 @@ mod test { use core::ops::ControlFlow; use crate::any::{LtTypeId, TypeNameable}; + use crate::hkt::hkt; use super::*; @@ -84,16 +85,16 @@ mod test { impl<'ctx, X> Hint<'ctx, Y> for X { fn hint<'a>( &'a mut self, - visitor: &'a mut Visitor<'a, 'ctx>, - hint: <Y as HintMeta<'ctx>>::Hint<'a>, + visitor: Visitor<'a, 'ctx, SyncEffect>, + hint: <Y as HintMeta<'ctx>>::Hint, ) -> ControlFlow<()> { todo!() } fn known<'a>( &'a mut self, - hint: &'a <Y as HintMeta<'ctx>>::Hint<'a>, - ) -> ControlFlow<(), <Y as HintMeta<'ctx>>::Known<'a>> + hint: &'a <Y as HintMeta<'ctx>>::Hint, + ) -> ControlFlow<(), any_t::T<'a, 'ctx, <Y as HintMeta<'ctx>>::KnownHkt>> where 'ctx: 'a, { @@ -101,10 +102,12 @@ mod test { } } + hkt!((any_t): for<'a, 'ctx> KnownHkt => ()); + impl<'ctx> HintMeta<'ctx> for Y { - type Known<'a> = () where 'ctx: 'a; + type KnownHkt = KnownHkt<'ctx>; - type Hint<'a> = () where 'ctx: 'a; + type Hint = (); } let x = X; @@ -115,7 +118,5 @@ mod test { } id(y); - - // todo!(); } } |