implement initial state for words criterion

This commit is contained in:
many 2021-02-24 15:59:19 +01:00 committed by Kerollmops
parent 3415812b06
commit b5b7ec0162
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -60,23 +60,36 @@ impl<'t> Criterion for Words<'t> {
self.candidates = Candidates::default(); self.candidates = Candidates::default();
}, },
(Some(qt), Allowed(candidates)) => { (Some(qt), Allowed(candidates)) => {
let bucket_candidates = match self.parent {
Some(_) => take(&mut self.bucket_candidates),
None => candidates.clone(),
};
let mut found_candidates = resolve_candidates(self.ctx, &qt, &mut self.candidates_cache)?; let mut found_candidates = resolve_candidates(self.ctx, &qt, &mut self.candidates_cache)?;
found_candidates.intersect_with(&candidates); found_candidates.intersect_with(&candidates);
candidates.difference_with(&found_candidates); candidates.difference_with(&found_candidates);
let bucket_candidates = match self.parent {
Some(_) => take(&mut self.bucket_candidates),
None => found_candidates.clone(),
};
return Ok(Some(CriterionResult { return Ok(Some(CriterionResult {
query_tree: Some(qt), query_tree: Some(qt),
candidates: found_candidates, candidates: found_candidates,
bucket_candidates, bucket_candidates,
})); }));
}, },
(Some(_qt), Forbidden(_candidates)) => { (Some(qt), Forbidden(candidates)) => {
todo!() let mut found_candidates = resolve_candidates(self.ctx, &qt, &mut self.candidates_cache)?;
found_candidates.difference_with(&candidates);
candidates.union_with(&found_candidates);
let bucket_candidates = match self.parent {
Some(_) => take(&mut self.bucket_candidates),
None => found_candidates.clone(),
};
return Ok(Some(CriterionResult {
query_tree: Some(qt),
candidates: found_candidates,
bucket_candidates,
}));
}, },
(None, Allowed(_)) => { (None, Allowed(_)) => {
let candidates = take(&mut self.candidates).into_inner(); let candidates = take(&mut self.candidates).into_inner();