mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +01:00
Revert "feat: Introduce multiple Iterator impl for Matches"
This reverts commit c594597a01
.
This commit is contained in:
parent
34d2850d28
commit
2cc5fbde1a
@ -2,7 +2,6 @@ pub mod criterion;
|
|||||||
mod query_builder;
|
mod query_builder;
|
||||||
mod distinct_map;
|
mod distinct_map;
|
||||||
|
|
||||||
use std::iter::FusedIterator;
|
|
||||||
use std::slice::Windows;
|
use std::slice::Windows;
|
||||||
|
|
||||||
use sdset::SetBuf;
|
use sdset::SetBuf;
|
||||||
@ -83,10 +82,9 @@ pub struct QueryIndexGroups<'a, 'b> {
|
|||||||
windows: Windows<'b, usize>,
|
windows: Windows<'b, usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for QueryIndexGroups<'a, '_> {
|
impl<'a, 'b> Iterator for QueryIndexGroups<'a, 'b> {
|
||||||
type Item = &'a [Match];
|
type Item = &'a [Match];
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
self.windows.next().map(|range| {
|
self.windows.next().map(|range| {
|
||||||
match *range {
|
match *range {
|
||||||
@ -95,56 +93,10 @@ impl<'a> Iterator for QueryIndexGroups<'a, '_> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
|
||||||
self.windows.size_hint()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
// impl ExactSizeIterator for QueryIndexGroups<'_, '_> {
|
||||||
fn count(self) -> usize {
|
// fn len(&self) -> usize {
|
||||||
self.len()
|
// self.windows.len() // FIXME (+1) ?
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
#[inline]
|
|
||||||
fn nth(&mut self, n: usize) -> Option<Self::Item> {
|
|
||||||
self.windows.nth(n).map(|range| {
|
|
||||||
match *range {
|
|
||||||
[left, right] => &self.matches[left..right],
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn last(self) -> Option<Self::Item> {
|
|
||||||
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::Item> {
|
|
||||||
self.windows.next_back().map(|range| {
|
|
||||||
match *range {
|
|
||||||
[left, right] => &self.matches[left..right],
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user