Diffstat (limited to 'src/protocol/walker/hint.rs')
| -rw-r--r-- | src/protocol/walker/hint.rs | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/protocol/walker/hint.rs b/src/protocol/walker/hint.rs index b5ebd37..a4d51d5 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, WithContextLt}, - bijective_higher_ranked_type, - effect::{Effect, Future}, - hkt::AnySizedSend, - 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 (); + + type T: { Send + Sized }; + + type HigherRanked: { }; + } +} + /// Meta information for the hint. /// /// This gives the visitor more information to work from when selecting a hint. @@ -21,13 +26,13 @@ pub trait HintMeta<'ctx> { /// /// This should be information easy to get without changing the state of the walker /// in an irreversible way. - type Known: AnySizedSend::MemberType; + type Known: HintKnown::MemberType; /// Extra information the visitor can give to the walker about what it is expecting. type Hint; } -pub type Known<'a, 'ctx, Protocol> = AnySizedSend::T<'a, <Protocol as HintMeta<'ctx>>::Known>; +pub type Known<'a, 'ctx, Protocol> = HintKnown::T<'a, <Protocol as HintMeta<'ctx>>::Known>; /// Object implementing the [`Hint`] protocol. pub trait Hint<'ctx, Protocol: ?Sized + HintMeta<'ctx>, E: Effect> { @@ -47,24 +52,23 @@ pub trait Hint<'ctx, Protocol: ?Sized + HintMeta<'ctx>, E: Effect> { ) -> Future<'a, Result<Known<'a, 'ctx, Protocol>, ()>, E>; } -bijective_higher_ranked_type! { - pub type DynHint['ctx][Protocol, E]: WithContextLt['ctx][] - for<'a> - (dyn Hint<'ctx, Protocol, E> + Send + 'a) - where { - E: Effect, - Protocol: ?Sized + WithContextLt::MemberType<'ctx> + 'ctx, - } -} +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 + where { + Protocol: 'static, + E: Effect + }; -bijective_higher_ranked_type! { - pub type [][E][Protocol[][]]: TypeName[][] - for<'ctx> - (DynHint<'ctx, TypeName::T<'ctx, Protocol>, E>) - (DynHint<'ctx, Protocol, E>) - where { - E: Effect, - Protocol: ?Sized, + impl['a, 'ctx, Protocol, E] type HigherRanked['a, 'ctx] for dyn Hint<'ctx, Protocol, E> + Send + 'a = + HintProto<Protocol, E> + where { + Protocol: 'static, + E: Effect, + }; } } |