Diffstat (limited to 'src/protocol/walker/hint.rs')
| -rw-r--r-- | src/protocol/walker/hint.rs | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/protocol/walker/hint.rs b/src/protocol/walker/hint.rs index a4d51d5..9bb35e6 100644 --- a/src/protocol/walker/hint.rs +++ b/src/protocol/walker/hint.rs @@ -5,14 +5,19 @@ //! to the walker about what it is expecting. use crate::{ - any::{TypeName}, effect::{Effect, Future}, higher_ranked_trait, higher_ranked_type, hkt::Marker, protocol::Visitor, Flow + any::TypeName, + effect::{Effect, Future}, + higher_ranked_trait, higher_ranked_type, + hkt::Marker, + protocol::Visitor, + Flow, }; higher_ranked_trait! { - pub type class HintKnown for<'a> { - type Bound = &'a (); + pub type class HintKnown for<'a, 'ctx> { + type Bound = &'a &'ctx (); - type T: { Send + Sized }; + type T: { Send + Sized } where { 'ctx: 'a }; type HigherRanked: { }; } @@ -21,7 +26,7 @@ higher_ranked_trait! { /// Meta information for the hint. /// /// This gives the visitor more information to work from when selecting a hint. -pub trait HintMeta<'ctx> { +pub trait HintMeta: Send + Sync + 'static { /// Information known by the walker. /// /// This should be information easy to get without changing the state of the walker @@ -32,23 +37,23 @@ pub trait HintMeta<'ctx> { type Hint; } -pub type Known<'a, 'ctx, Protocol> = HintKnown::T<'a, <Protocol as HintMeta<'ctx>>::Known>; +pub type Known<'a, 'ctx, Protocol> = HintKnown::T<'a, 'ctx, <Protocol as HintMeta>::Known>; /// Object implementing the [`Hint`] protocol. -pub trait Hint<'ctx, Protocol: ?Sized + HintMeta<'ctx>, E: Effect> { +pub trait Hint<'ctx, Protocol: ?Sized + HintMeta, E: Effect> { /// Hint to the walker to use the `P` protocol. /// /// This should only be called once per [`RequestHint`]. fn hint<'a>( &'a mut self, visitor: Visitor<'a, 'ctx>, - hint: <Protocol as HintMeta<'ctx>>::Hint, + hint: <Protocol as HintMeta>::Hint, ) -> Future<'a, Flow, E>; /// Ask the walker for information about it's support of the protocol. fn known<'a>( &'a mut self, - hint: &'a <Protocol as HintMeta<'ctx>>::Hint, + hint: &'a <Protocol as HintMeta>::Hint, ) -> Future<'a, Result<Known<'a, 'ctx, Protocol>, ()>, E>; } @@ -57,13 +62,13 @@ pub struct HintProto<Protocol: ?Sized, E: Effect>(Marker<(*const Protocol, E)>); higher_ranked_type! { impl TypeName { impl['a, 'ctx, Protocol, E] type T['a, 'ctx] for HintProto<Protocol, E> = - dyn Hint<'ctx, Protocol, E> + Send + 'a + dyn Hint<'ctx, Protocol, E> + Send + Sync + 'a where { Protocol: 'static, E: Effect }; - impl['a, 'ctx, Protocol, E] type HigherRanked['a, 'ctx] for dyn Hint<'ctx, Protocol, E> + Send + 'a = + impl['a, 'ctx, Protocol, E] type HigherRanked['a, 'ctx] for dyn Hint<'ctx, Protocol, E> + Send + Sync + 'a = HintProto<Protocol, E> where { Protocol: 'static, |