Implement IntoIterator() for DiffVector
//! us to track something like the average.
use std::ops::{AddAssign, Neg, Mul};
+use std::iter::Iterator;
use ::Data;
@@ -140,6 +141,14 @@ impl<R> DiffVector<R> {
}
}
+impl<R> IntoIterator for DiffVector<R> {
+ type Item = R;
+ type IntoIter = ::std::vec::IntoIter<R>;
+ fn into_iter(self) -> Self::IntoIter {
+ self.buffer.into_iter()
+ }
+}
+
impl<R: Monoid> Monoid for DiffVector<R> {
#[inline(always)] fn is_zero(&self) -> bool {
self.buffer.iter().all(|x| x.is_zero())
