From 2cc5fbde1a6a3c0d6de9be670afc9636e555153a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sun, 6 Jan 2019 21:26:27 +0100 Subject: [PATCH] Revert "feat: Introduce multiple Iterator impl for Matches" This reverts commit c594597a01422087a66e78bdfddd32d5abc99ad2. --- src/rank/mod.rs | 60 +++++-------------------------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/src/rank/mod.rs b/src/rank/mod.rs index 2023cb266..5416ca882 100644 --- a/src/rank/mod.rs +++ b/src/rank/mod.rs @@ -2,7 +2,6 @@ pub mod criterion; mod query_builder; mod distinct_map; -use std::iter::FusedIterator; use std::slice::Windows; use sdset::SetBuf; @@ -83,10 +82,9 @@ pub struct QueryIndexGroups<'a, 'b> { windows: Windows<'b, usize>, } -impl<'a> Iterator for QueryIndexGroups<'a, '_> { +impl<'a, 'b> Iterator for QueryIndexGroups<'a, 'b> { type Item = &'a [Match]; - #[inline] fn next(&mut self) -> Option { self.windows.next().map(|range| { match *range { @@ -95,56 +93,10 @@ impl<'a> Iterator for QueryIndexGroups<'a, '_> { } }) } - - #[inline] - fn size_hint(&self) -> (usize, Option) { - self.windows.size_hint() - } - - #[inline] - fn count(self) -> usize { - self.len() - } - - #[inline] - fn nth(&mut self, n: usize) -> Option { - self.windows.nth(n).map(|range| { - match *range { - [left, right] => &self.matches[left..right], - _ => unreachable!(), - } - }) - } - - #[inline] - fn last(self) -> Option { - let (matches, windows) = (self.matches, self.windows); - windows.last().map(|range| { - match *range { - [left, right] => &matches[left..right], - _ => unreachable!(), - } - }) - } } -impl ExactSizeIterator for QueryIndexGroups<'_, '_> { - #[inline] - fn len(&self) -> usize { - self.windows.len() - } -} - -impl FusedIterator for QueryIndexGroups<'_, '_> { } - -impl DoubleEndedIterator for QueryIndexGroups<'_, '_> { - #[inline] - fn next_back(&mut self) -> Option { - self.windows.next_back().map(|range| { - match *range { - [left, right] => &self.matches[left..right], - _ => unreachable!(), - } - }) - } -} +// impl ExactSizeIterator for QueryIndexGroups<'_, '_> { +// fn len(&self) -> usize { +// self.windows.len() // FIXME (+1) ? +// } +// }