Diffstat (limited to 'src/protocol/walker/hint.rs')
-rw-r--r--src/protocol/walker/hint.rs65
1 files changed, 41 insertions, 24 deletions
diff --git a/src/protocol/walker/hint.rs b/src/protocol/walker/hint.rs
index 148b8f2..b013c61 100644
--- a/src/protocol/walker/hint.rs
+++ b/src/protocol/walker/hint.rs
@@ -13,21 +13,38 @@ use crate::{
Flow,
};
-higher_ranked_trait! {
- pub type class Meta for<'a, 'ctx> {
- type Bound = &'a &'ctx ();
+#[allow(non_snake_case)]
+pub mod Meta {
+ pub trait MemberTypeForLt<'a, 'ctx: 'a, B> {
+ type T: ?Sized + LowerTypeWithBound<'a, 'ctx, &'a &'ctx (), Higher = Self>;
+ }
+
+ pub trait MemberType: for<'a, 'ctx> MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> {}
- type T: { Send + Sync + Sized } where { 'ctx: 'a };
+ impl<T: ?Sized> MemberType for T where T: for<'a, 'ctx> MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> {}
- type HigherRanked: { };
+ pub trait LowerTypeWithBound<'a, 'ctx: 'a, B>: 'a + Send + Sync + Sized {
+ type Higher: ?Sized + MemberTypeForLt<'a, 'ctx, &'a &'ctx (), T = Self> + MemberType;
}
-}
-higher_ranked_type! {
- impl Meta {
- impl['a, 'ctx] type T['a, 'ctx] for () = ();
- impl['a, 'ctx] type HigherRanked['a, 'ctx] for () = ();
+ pub trait LowerType<'a, 'ctx: 'a>: LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()> {}
+
+ impl<'a, 'ctx: 'a, T: ?Sized> LowerType<'a, 'ctx> for T where
+ T: LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()>
+ {
}
+
+ pub type T<'a, 'ctx, __> = <__ as MemberTypeForLt<'a, 'ctx, &'a &'ctx ()>>::T;
+ pub type HigherRanked<'a, 'ctx, __> =
+ <__ as LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()>>::Higher;
+}
+
+impl<'a, 'ctx> Meta::MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> for () {
+ type T = ();
+}
+
+impl<'a, 'ctx: 'a> Meta::LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()> for () {
+ type Higher = ();
}
/// Meta information for the hint.
@@ -71,20 +88,20 @@ pub trait Hint<'ctx, Protocol: ?Sized + HintMeta> {
pub struct HintProto<Protocol: ?Sized>(Marker<Protocol>);
-higher_ranked_type! {
- impl TypeName {
- impl['a, 'ctx, Protocol] type T['a, 'ctx] for HintProto<Protocol> =
- dyn Hint<'ctx, Protocol> + Send + Sync + 'a
- where {
- Protocol: ?Sized + 'static,
- };
-
- impl['a, 'ctx, Protocol] type HigherRanked['a, 'ctx] for dyn Hint<'ctx, Protocol> + Send + Sync + 'a =
- HintProto<Protocol>
- where {
- Protocol: ?Sized + 'static,
- };
- }
+impl<'a, 'ctx, Protocol: ?Sized> TypeName::MemberTypeForLt<'a, 'ctx, &'a &'ctx ()>
+ for HintProto<Protocol>
+where
+ Protocol: HintMeta,
+{
+ type T = dyn Hint<'ctx, Protocol> + Send + Sync + 'a;
+}
+
+impl<'a, 'ctx, Protocol: ?Sized> TypeName::LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()>
+ for dyn Hint<'ctx, Protocol> + Send + Sync + 'a
+where
+ Protocol: HintMeta,
+{
+ type Higher = HintProto<Protocol>;
}
pub fn hint_protocol<