diff options
author | Paul Masurel <paul.masurel@gmail.com> | 2018-08-20 09:21:32 +0900 |
---|---|---|
committer | Paul Masurel <paul.masurel@gmail.com> | 2018-08-20 09:21:32 +0900 |
commit | a0a284fe91c0ca16961875959300fcf917327c43 (patch) | |
tree | 241bcbc9d3b03d26c8a32c7215e746c4cf6ff653 /src/query/scorer.rs | |
parent | 0feeef26843e17d731cd06080d8f2a8f7819bd90 (diff) |
Added a full fledge empty query and relyign on it in QueryParser, instead of using an empty clause.
Diffstat (limited to 'src/query/scorer.rs')
-rw-r--r-- | src/query/scorer.rs | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/query/scorer.rs b/src/query/scorer.rs index a94b03a..186e75a 100644 --- a/src/query/scorer.rs +++ b/src/query/scorer.rs @@ -50,33 +50,6 @@ impl Scorer for Box<Scorer> { } } -/// `EmptyScorer` is a dummy `Scorer` in which no document matches. -/// -/// It is useful for tests and handling edge cases. -pub struct EmptyScorer; - -impl DocSet for EmptyScorer { - fn advance(&mut self) -> bool { - false - } - - fn doc(&self) -> DocId { - panic!( - "You may not call .doc() on a scorer \ - where the last call to advance() did not return true." - ); - } - - fn size_hint(&self) -> u32 { - 0 - } -} - -impl Scorer for EmptyScorer { - fn score(&mut self) -> Score { - 0f32 - } -} /// Wraps a `DocSet` and simply returns a constant `Scorer`. /// The `ConstScorer` is useful if you have a `DocSet` where @@ -135,21 +108,3 @@ impl<TDocSet: DocSet + 'static> Scorer for ConstScorer<TDocSet> { 1f32 } } - -#[cfg(test)] -mod tests { - use super::EmptyScorer; - use DocSet; - - #[test] - fn test_empty_scorer() { - let mut empty_scorer = EmptyScorer; - assert!(!empty_scorer.advance()); - } - - #[test] - #[should_panic] - fn test_empty_scorer_panic_on_doc_call() { - EmptyScorer.doc(); - } -} |