Diffstat (limited to 'src/protocol/walker/hint.rs')
-rw-r--r--src/protocol/walker/hint.rs107
1 files changed, 49 insertions, 58 deletions
diff --git a/src/protocol/walker/hint.rs b/src/protocol/walker/hint.rs
index 9b86ded..db7c762 100644
--- a/src/protocol/walker/hint.rs
+++ b/src/protocol/walker/hint.rs
@@ -31,112 +31,103 @@ pub trait HintMeta: InEnvironment + type_name::Static {
}
/// Object implementing the [`Hint`] protocol.
-pub trait Hint<'ctx, Protocol: ?Sized + HintMeta>: DynBind<Protocol::Env> {
+pub trait Hint<'src, Protocol: ?Sized + HintMeta>: DynBind<Protocol::Env> {
/// Hint to the walker to use the `P` protocol.
///
/// This should only be called once per [`RequestHint`].
- fn hint<'this: 'e, 'visitor: 'e, 'lt: 'e, 'hint: 'e, 'e>(
- &'this mut self,
- visitor: DynVisitorWith<'visitor, 'lt, 'ctx, Protocol>,
- hint: WithLt<'hint, Protocol::Hint>,
- ) -> Canonical<'e, VisitResult, Protocol::Env>
- where
- 'ctx: 'this + 'visitor + 'hint;
+ fn hint<'r>(
+ &'r mut self,
+ visitor: DynVisitorWith<'r, 'src, Protocol>,
+ hint: WithLt<'r, Protocol::Hint>,
+ ) -> Canonical<'r, VisitResult, Protocol::Env>;
/// Ask the walker for information about it's support of the protocol.
- fn known<'a>(
- &'a mut self,
- hint: &'a WithLt<'a, Protocol::Hint>,
- ) -> Canonical<'a, Result<WithLt<'a, Protocol::Known>, ()>, Protocol::Env>
+ fn known<'r>(
+ &'r mut self,
+ hint: &'r WithLt<'r, Protocol::Hint>,
+ ) -> Canonical<'r, Result<WithLt<'r, Protocol::Known>, ()>, Protocol::Env>
where
- WithLt<'a, Protocol::Known>: DynBind<Protocol::Env>;
+ WithLt<'r, Protocol::Known>: DynBind<Protocol::Env> + Sized;
}
#[derive(SendSync)]
-pub struct DynVisitorWith<'temp, 'lt, 'ctx, Protocol: ?Sized + HintMeta> {
- visitor: DynVisitor<'temp, 'lt, 'ctx, Protocol::Env>,
+pub struct DynVisitorWith<'r, 'src, Protocol: ?Sized + HintMeta> {
+ visitor: DynVisitor<'r, 'src, Protocol::Env>,
_marker: Marker<Protocol>,
}
-impl<'temp, 'lt: 'temp, 'ctx: 'lt, Protocol: ?Sized + HintMeta> DynVisitorWith<'temp, 'lt, 'ctx, Protocol> {
- pub fn new<T>(visitor: &'temp mut T) -> Self
+impl<'r, 'src, Protocol: ?Sized + HintMeta> DynVisitorWith<'r, 'src, Protocol> {
+ pub fn new<T>(visitor: &'r mut T) -> Self
where
- T: AnyTraitDynBind<'lt, 'ctx, Protocol::Env>,
+ T: AnyTraitDynBind<'src, Protocol::Env>,
{
Self {
- visitor: DynVisitor(visitor),
+ visitor: DynVisitor::new(visitor),
_marker: Default::default(),
}
}
- pub fn as_known(&mut self) -> &mut type_name::Lowered<'lt, 'ctx, Protocol> {
+ pub fn as_known(&mut self) -> &mut type_name::Lowered<'_, 'src, Protocol> {
self.visitor
- .upcast_mut::<type_name::Lowered<'lt, 'ctx, Protocol>>()
+ .upcast_mut::<type_name::Lowered<'_, 'src, Protocol>>()
.unwrap()
}
- pub fn into_inner(self) -> DynVisitor<'temp, 'lt, 'ctx, Protocol::Env> {
+ pub fn into_inner(self) -> DynVisitor<'r, 'src, Protocol::Env> {
self.visitor
}
}
-impl<'temp, 'lt, 'ctx, Protocol: ?Sized + HintMeta> Deref for DynVisitorWith<'temp, 'lt, 'ctx, Protocol> {
- type Target = DynVisitor<'temp, 'lt, 'ctx, Protocol::Env>;
+impl<'r, 'src, Protocol: ?Sized + HintMeta> Deref for DynVisitorWith<'r, 'src, Protocol> {
+ type Target = DynVisitor<'r, 'src, Protocol::Env>;
fn deref(&self) -> &Self::Target {
&self.visitor
}
}
-impl<'temp, 'lt, 'ctx, Protocol: ?Sized + HintMeta> DerefMut for DynVisitorWith<'temp, 'lt, 'ctx, Protocol> {
+impl<'r, 'src, Protocol: ?Sized + HintMeta> DerefMut for DynVisitorWith<'r, 'src, Protocol> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.visitor
}
}
-const _: () = {
- pub struct HintProto<Protocol: ?Sized>(Marker<Protocol>);
-
- impl<'a, 'ctx, Protocol: ?Sized> type_name::Lower<'a, 'ctx, &'a &'ctx ()> for HintProto<Protocol>
- where
- Protocol: HintMeta,
- {
- type Lowered = dyn Hint<'ctx, Protocol> + 'a;
- }
+impl<'u, 'src, Protocol: ?Sized> type_name::Lower<'u, 'src, &'u &'src ()> for dyn Hint<'static, Protocol>
+where
+ Protocol: HintMeta,
+{
+ type Lowered = dyn Hint<'src, Protocol> + 'u;
+}
- impl<'a, 'ctx, Protocol: ?Sized> type_name::Raise<'a, 'ctx, &'a &'ctx ()>
- for dyn Hint<'ctx, Protocol> + 'a
- where
- Protocol: HintMeta,
- {
- type Raised = HintProto<Protocol>;
- }
-};
+impl<'u, 'src, Protocol: ?Sized> type_name::Raise<'u, 'src, &'u &'src ()>
+ for dyn Hint<'src, Protocol> + 'u
+where
+ Protocol: HintMeta,
+{
+ type Raised = dyn Hint<'static, Protocol>;
+}
pub fn hint_protocol<
- 'ctx: 'walker + 'visitor + 'hint,
- 'walker: 'e,
- 'visitor: 'e,
- 'hint: 'e,
- 'lt: 'e,
- 'e,
- Protocol: ?Sized + type_name::WithLt<'static, 'static>,
+ 'r,
+ 'src,
+ Protocol: ?Sized + type_name::WithLt<'r, 'src>,
E,
T,
>(
- walker: DynWalker<'walker, 'lt, 'ctx, E>,
- visitor: &'visitor mut T,
- hint: WithLt<'hint, <type_name::Raised<'static, 'static, Protocol> as HintMeta>::Hint>,
-) -> Canonical<'e, VisitResult<()>, E>
+ walker: DynWalker<'r, 'src, E>,
+ visitor: &'r mut T,
+ hint: WithLt<'r, <type_name::Raised<'r, 'src, Protocol> as HintMeta>::Hint>,
+) -> Canonical<'r, VisitResult<()>, E>
where
E: Environment,
- T: AnyTrait<'lt, 'ctx> + DynBind<E>,
- type_name::Raised<'static, 'static, Protocol>: HintMeta<Env = E>,
+ T: AnyTrait<'src> + DynBind<E>,
+ type_name::Raised<'r, 'src, Protocol>: HintMeta<Env = E>,
+ WithLt<'r, <type_name::Raised<'r, 'src, Protocol> as HintMeta>::Hint>: Sized,
{
if let Some(object) = walker
- .0
- .cast_mut()
- .upcast_mut::<dyn Hint<'ctx, type_name::Raised<'static, 'static, Protocol>> + '_>()
+ .into_inner()
+ .as_any_trait_mut()
+ .upcast_mut::<dyn Hint<'src, type_name::Raised<'r, 'src, Protocol>> + 'r>()
{
object
.hint(DynVisitorWith::new(visitor), hint)