Diffstat (limited to 'src/protocol/walker/hint.rs')
| -rw-r--r-- | src/protocol/walker/hint.rs | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/protocol/walker/hint.rs b/src/protocol/walker/hint.rs index 2d723e4..52da09b 100644 --- a/src/protocol/walker/hint.rs +++ b/src/protocol/walker/hint.rs @@ -31,11 +31,9 @@ pub trait HintMeta<'ctx> { pub type Known<'a, 'ctx, Protocol> = AnySend::T<'a, 'ctx, <Protocol as HintMeta<'ctx>>::Known>; /// Object implementing the [`Hint`] protocol. -pub trait Hint<'ctx, Protocol: ?Sized + HintMeta<'ctx>, E> -where - E: Effect<'ctx>, - E: for<'a> Effect<'ctx>, -{ +pub trait Hint<'ctx, Protocol: ?Sized + HintMeta<'ctx>> { + type Effect: Effect<'ctx>; + /// Hint to the walker to use the `P` protocol. /// /// This should only be called once per [`RequestHint`]. @@ -43,25 +41,25 @@ where &'a mut self, visitor: Visitor<'a, 'ctx>, hint: <Protocol as HintMeta<'ctx>>::Hint, - ) -> Future<'a, 'ctx, ControlFlow<(), ()>, E>; + ) -> Future<'a, 'ctx, ControlFlow<(), ()>, Self::Effect>; /// 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, - ) -> Future<'a, 'ctx, ControlFlow<(), Known<'a, 'ctx, Protocol>>, E>; + ) -> Future<'a, 'ctx, ControlFlow<(), Known<'a, 'ctx, Protocol>>, Self::Effect>; } nameable! { pub struct Name['a, 'ctx, Protocol, E]; - impl [Protocol::Name, E] for dyn Hint<'ctx, Protocol, E> + 'a where { + impl [Protocol::Name, E] for dyn Hint<'ctx, Protocol, Effect = E> + 'a where { Protocol: TypeNameable<'a, 'ctx> + ?Sized, E: Effect<'ctx>, 'ctx: 'a, } - impl [Protocol, E] where dyn Hint<'ctx, Protocol::Nameable, E> + 'a { + impl [Protocol, E] where dyn Hint<'ctx, Protocol::Nameable, Effect = E> + 'a { Protocol: TypeName<'a, 'ctx> + ?Sized, E: Effect<'ctx>, 'ctx: 'a, @@ -92,23 +90,22 @@ mod test { impl for Y where {} } - impl<'ctx, E> Hint<'ctx, Y, E> for X<'ctx> - where - E: Effect<'ctx>, - { + impl<'ctx> Hint<'ctx, Y> for X<'ctx> { + type Effect = Blocking; + fn hint<'a>( &'a mut self, _visitor: Visitor<'a, 'ctx>, _hint: <Y as HintMeta<'ctx>>::Hint, - ) -> Future<'a, 'ctx, ControlFlow<(), ()>, E> { + ) -> Future<'a, 'ctx, ControlFlow<(), ()>, Self::Effect> { todo!() } fn known<'a>( &'a mut self, _hint: &'a <Y as HintMeta<'ctx>>::Hint, - ) -> Future<'a, 'ctx, ControlFlow<(), Known<'a, 'ctx, Y>>, E> { - E::wrap(async { ControlFlow::Continue(&mut *self.0) }) + ) -> Future<'a, 'ctx, ControlFlow<(), Known<'a, 'ctx, Y>>, Self::Effect> { + Self::Effect::wrap(async { ControlFlow::Continue(&mut *self.0) }) } } @@ -124,7 +121,7 @@ mod test { let mut z = 42; let mut x = X(&mut z); - let y: &mut dyn Hint<'_, Y, Blocking> = &mut x; + let y: &mut dyn Hint<'_, Y, Effect = Blocking> = &mut x; fn id<'a, 'ctx, T: ?Sized + TypeNameable<'a, 'ctx>>(_x: &T) {} id(y); |