Update to iter stabilization.

`AdditiveIterator::sum` and `MultiplicativeIterator::product` now take bare self.
This commit is contained in:
gifnksm 2014-11-27 23:06:06 +09:00
parent 8f8530fc00
commit b20dda2307
3 changed files with 8 additions and 8 deletions

View File

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

View File

@ -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 { 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(); let init: Complex<A> = Zero::zero();
self.fold(init, |acc, x| acc + x) self.fold(init, |acc, x| acc + x)
} }
} }
impl<A: Clone + Num, T: Iterator<Complex<A>>> MultiplicativeIterator<Complex<A>> for T { 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(); let init: Complex<A> = One::one();
self.fold(init, |acc, x| acc * x) self.fold(init, |acc, x| acc * x)
} }

View File

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