Diffstat (limited to 'src/protocol/visitor/sequence.rs')
-rw-r--r--src/protocol/visitor/sequence.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/protocol/visitor/sequence.rs b/src/protocol/visitor/sequence.rs
index 4f18f49..e748eef 100644
--- a/src/protocol/visitor/sequence.rs
+++ b/src/protocol/visitor/sequence.rs
@@ -1,6 +1,6 @@
use crate::{
any::TypeName,
- effect::{Effect, Effective, ErasedEffective},
+ effect::{Effect, Effective, ErasedEffective, ReadyExt as _},
higher_ranked_type,
hkt::Marker,
protocol::{
@@ -17,10 +17,12 @@ use super::VisitResult;
/// This protocol uses a scope to give temporary control to the visitor.
/// The visitor will drive the walker for each item.
pub trait Sequence<'ctx, E: Effect> {
- fn visit<'a>(
+ fn visit<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
- scope: DynSequenceScope<'a, 'ctx, E>,
- ) -> ErasedEffective<'a, VisitResult<DynSequenceScope<'a, 'ctx, E>>, E>;
+ scope: DynSequenceScope<'b, 'ctx, E>,
+ ) -> ErasedEffective<'c, VisitResult<DynSequenceScope<'b, 'ctx, E>>, E>
+ where
+ 'ctx: 'a;
}
pub struct SequenceProto<E: Effect>(Marker<E>);
@@ -44,7 +46,12 @@ higher_ranked_type! {
pub trait SequenceScope<'ctx, E: Effect> {
fn size_hint(&mut self) -> ErasedEffective<'_, (usize, Option<usize>), E>;
- fn next<'a>(&'a mut self, visitor: DynVisitor<'a, 'ctx>) -> ErasedEffective<'a, Flow, E>;
+ fn next<'a: 'c, 'b: 'c, 'c>(
+ &'a mut self,
+ visitor: DynVisitor<'b, 'ctx>,
+ ) -> ErasedEffective<'c, Flow, E>
+ where
+ 'ctx: 'c + 'a + 'b;
}
pub type DynSequenceScope<'a, 'ctx, E> = &'a mut (dyn SequenceScope<'ctx, E> + Send + Sync + 'a);
@@ -96,6 +103,6 @@ pub fn visit_sequence<'a, 'ctx, E: Effect>(
object.visit(scope)
} else {
// If the visitor doesn't support request hint then we continue.
- E::ready(VisitResult::Skipped(scope)).into_erased()
+ VisitResult::Skipped(scope).ready()
}
}