Quellcode durchsuchen

Update to iter stabilization.

`AdditiveIterator::sum` and `MultiplicativeIterator::product` now take bare self.
gifnksm vor 10 Jahren
Ursprung
Commit
b20dda2307
3 geänderte Dateien mit 8 neuen und 8 gelöschten Zeilen
  1. 4 4
      src/bigint.rs
  2. 2 2
      src/complex.rs
  3. 2 2
      src/rational.rs

+ 4 - 4
src/bigint.rs

@@ -740,14 +740,14 @@ impl FromStrRadix for BigUint {
 }
 
 impl<T: Iterator<BigUint>> AdditiveIterator<BigUint> for T {
-    fn sum(&mut self) -> BigUint {
+    fn sum(self) -> BigUint {
         let init: BigUint = Zero::zero();
         self.fold(init, |acc, x| acc + x)
     }
 }
 
 impl<T: Iterator<BigUint>> MultiplicativeIterator<BigUint> for T {
-    fn product(&mut self) -> BigUint {
+    fn product(self) -> BigUint {
         let init: BigUint = One::one();
         self.fold(init, |acc, x| acc * x)
     }
@@ -1388,14 +1388,14 @@ impl<R: Rng> RandBigInt for R {
 }
 
 impl<T: Iterator<BigInt>> AdditiveIterator<BigInt> for T {
-    fn sum(&mut self) -> BigInt {
+    fn sum(self) -> BigInt {
         let init: BigInt = Zero::zero();
         self.fold(init, |acc, x| acc + x)
     }
 }
 
 impl<T: Iterator<BigInt>> MultiplicativeIterator<BigInt> for T {
-    fn product(&mut self) -> BigInt {
+    fn product(self) -> BigInt {
         let init: BigInt = One::one();
         self.fold(init, |acc, x| acc * x)
     }

+ 2 - 2
src/complex.rs

@@ -176,14 +176,14 @@ impl<T: fmt::Show + Num + PartialOrd> fmt::Show for Complex<T> {
 }
 
 impl<A: Clone + Num, T: Iterator<Complex<A>>> AdditiveIterator<Complex<A>> for T {
-    fn sum(&mut self) -> Complex<A> {
+    fn sum(self) -> Complex<A> {
         let init: Complex<A> = Zero::zero();
         self.fold(init, |acc, x| acc + x)
     }
 }
 
 impl<A: Clone + Num, T: Iterator<Complex<A>>> MultiplicativeIterator<Complex<A>> for T {
-    fn product(&mut self) -> Complex<A> {
+    fn product(self) -> Complex<A> {
         let init: Complex<A> = One::one();
         self.fold(init, |acc, x| acc * x)
     }

+ 2 - 2
src/rational.rs

@@ -384,14 +384,14 @@ impl<T: FromStrRadix + Clone + Integer + PartialOrd>
 }
 
 impl<A: Clone + Integer + PartialOrd, T: Iterator<Ratio<A>>> AdditiveIterator<Ratio<A>> for T {
-    fn sum(&mut self) -> Ratio<A> {
+    fn sum(self) -> Ratio<A> {
         let init: Ratio<A> = Zero::zero();
         self.fold(init, |acc, x| acc + x)
     }
 }
 
 impl<A: Clone + Integer + PartialOrd, T: Iterator<Ratio<A>>> MultiplicativeIterator<Ratio<A>> for T {
-    fn product(&mut self) -> Ratio<A> {
+    fn product(self) -> Ratio<A> {
         let init: Ratio<A> = One::one();
         self.fold(init, |acc, x| acc * x)
     }