Browse Source

Removed needless `Product[Into]Iter` types

Robert Bennett 1 year ago
parent
commit
c2e97cc6d2
1 changed files with 4 additions and 32 deletions
  1. 4 32
      numbat/src/product.rs

+ 4 - 32
numbat/src/product.rs

@@ -145,10 +145,8 @@ impl<Factor: Clone + Ord + Canonicalize, const CANONICALIZE: bool> Product<Facto
         product
     }
 
-    pub fn iter(&self) -> ProductIter<Factor> {
-        ProductIter {
-            inner: self.factors.iter(),
-        }
+    pub fn iter(&self) -> std::slice::Iter<'_, Factor> {
+        self.factors.iter()
     }
 
     #[cfg(test)]
@@ -245,13 +243,11 @@ impl<Factor: Clone + Ord + Canonicalize + Eq, const CANONICALIZE: bool> Eq
 }
 
 impl<Factor, const CANONICALIZE: bool> IntoIterator for Product<Factor, CANONICALIZE> {
-    type IntoIter = ProductIntoIter<Factor>;
+    type IntoIter = <Vec<Factor> as IntoIterator>::IntoIter;
     type Item = Factor;
 
     fn into_iter(self) -> Self::IntoIter {
-        ProductIntoIter {
-            inner: self.factors.into_iter(),
-        }
+        self.factors.into_iter()
     }
 }
 
@@ -277,30 +273,6 @@ impl<Factor: Clone + Ord + Canonicalize, const CANONICALIZE: bool> std::iter::Pr
     }
 }
 
-pub struct ProductIter<'a, Factor> {
-    inner: std::slice::Iter<'a, Factor>,
-}
-
-impl<'a, Factor> Iterator for ProductIter<'a, Factor> {
-    type Item = &'a Factor;
-
-    fn next(&mut self) -> Option<Self::Item> {
-        self.inner.next()
-    }
-}
-
-pub struct ProductIntoIter<Factor> {
-    inner: std::vec::IntoIter<Factor>,
-}
-
-impl<Factor> Iterator for ProductIntoIter<Factor> {
-    type Item = Factor;
-
-    fn next(&mut self) -> Option<Self::Item> {
-        self.inner.next()
-    }
-}
-
 #[cfg(test)]
 mod tests {
     use super::*;