summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2021-02-24 14:22:29 -0500
committerTavian Barnes <tavianator@tavianator.com>2021-02-24 14:22:29 -0500
commitaa310a561f9b6f430db74cf1dda30192501869e3 (patch)
treed207a46cf01e6a1bc651751e4775796906e278d0 /src
parent645dad796b4a99de3ab2813b1b4edb4c7f246ba9 (diff)
downloadacap-aa310a561f9b6f430db74cf1dda30192501869e3.tar.xz
exhaustive: Add a wrapper type for IntoIterator
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())
}
}