From 00a321374b8f2185ca50503c76c8346d77736bbc Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 7 Dec 2023 23:21:46 +0900 Subject: [PATCH] revset: parameterize candidates set of FilterRevset as well --- lib/src/default_revset_engine.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/src/default_revset_engine.rs b/lib/src/default_revset_engine.rs index 2cd82868b1..77e07729f7 100644 --- a/lib/src/default_revset_engine.rs +++ b/lib/src/default_revset_engine.rs @@ -306,12 +306,16 @@ fn predicate_fn_from_positions<'iter>( } #[derive(Debug)] -struct FilterRevset

{ - candidates: Box, +struct FilterRevset { + candidates: S, predicate: P, } -impl InternalRevset for FilterRevset

{ +impl InternalRevset for FilterRevset +where + S: InternalRevset, + P: ToPredicateFn, +{ fn iter<'a, 'index: 'a>( &'a self, index: CompositeIndex<'index>, @@ -328,7 +332,11 @@ impl InternalRevset for FilterRevset

{ } } -impl ToPredicateFn for FilterRevset

{ +impl ToPredicateFn for FilterRevset +where + S: ToPredicateFn, + P: ToPredicateFn, +{ fn to_predicate_fn<'a, 'index: 'a>( &'a self, index: CompositeIndex<'index>, @@ -703,13 +711,13 @@ impl<'index> EvaluationContext<'index> { .collect_vec(); if generation_from_roots == &(1..2) { let root_positions_set: HashSet<_> = root_positions.iter().copied().collect(); - let candidates = Box::new(RevWalkRevset::new(move |index| { + let candidates = RevWalkRevset::new(move |index| { Box::new( index .walk_revs(&head_positions, &[]) .take_until_roots(&root_positions), ) - })); + }); let predicate = as_pure_predicate_fn(move |_index, entry| { entry .parent_positions()