Skip to content

Commit

Permalink
Allow for non static predicate in the FilterCollector
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Mar 18, 2021
1 parent d2d0873 commit 4f32126
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/collector/filter_collector_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,24 @@ use crate::{Score, SegmentReader, TantivyError};
/// ```
pub struct FilterCollector<TCollector, TPredicate, TPredicateValue: FastValue>
where
TPredicate: 'static,
TPredicate: 'static + Clone,
{
field: Field,
collector: TCollector,
predicate: &'static TPredicate,
predicate: TPredicate,
t_predicate_value: PhantomData<TPredicateValue>,
}

impl<TCollector, TPredicate, TPredicateValue: FastValue>
FilterCollector<TCollector, TPredicate, TPredicateValue>
where
TCollector: Collector + Send + Sync,
TPredicate: Fn(TPredicateValue) -> bool + Send + Sync,
TPredicate: Fn(TPredicateValue) -> bool + Send + Sync + Clone,
{
/// Create a new FilterCollector.
pub fn new(
field: Field,
predicate: &'static TPredicate,
predicate: TPredicate,
collector: TCollector,
) -> FilterCollector<TCollector, TPredicate, TPredicateValue> {
FilterCollector {
Expand All @@ -89,7 +89,7 @@ impl<TCollector, TPredicate, TPredicateValue: FastValue> Collector
for FilterCollector<TCollector, TPredicate, TPredicateValue>
where
TCollector: Collector + Send + Sync,
TPredicate: 'static + Fn(TPredicateValue) -> bool + Send + Sync,
TPredicate: 'static + Fn(TPredicateValue) -> bool + Send + Sync + Clone,
TPredicateValue: FastValue,
{
// That's the type of our result.
Expand Down Expand Up @@ -133,7 +133,7 @@ where
Ok(FilterSegmentCollector {
fast_field_reader,
segment_collector,
predicate: self.predicate,
predicate: self.predicate.clone(),
t_predicate_value: PhantomData,
})
}
Expand All @@ -157,7 +157,7 @@ where
{
fast_field_reader: FastFieldReader<TPredicateValue>,
segment_collector: TSegmentCollector,
predicate: &'static TPredicate,
predicate: TPredicate,
t_predicate_value: PhantomData<TPredicateValue>,
}

Expand Down

0 comments on commit 4f32126

Please sign in to comment.