summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exhaustive.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/exhaustive.rs b/src/exhaustive.rs
index 37af4c6..320994e 100644
--- a/src/exhaustive.rs
+++ b/src/exhaustive.rs
@@ -43,20 +43,24 @@ impl<T> FromIterator<T> for ExhaustiveSearch<T> {
}
}
-impl<T> IntoIterator for ExhaustiveSearch<T> {
+/// An iterator that moves values out of an exhaustive index.
+#[derive(Debug)]
+pub struct IntoIter<T>(std::vec::IntoIter<T>);
+
+impl<T> Iterator for IntoIter<T> {
type Item = T;
- type IntoIter = std::vec::IntoIter<T>;
- fn into_iter(self) -> Self::IntoIter {
- self.0.into_iter()
+ fn next(&mut self) -> Option<T> {
+ self.0.next()
}
}
-impl<T> Extend<T> for ExhaustiveSearch<T> {
- fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
- for value in iter {
- self.push(value);
- }
+impl<T> IntoIterator for ExhaustiveSearch<T> {
+ type Item = T;
+ type IntoIter = IntoIter<T>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ IntoIter(self.0.into_iter())
}
}