diff options
| author | bors <bors@rust-lang.org> | 2013-08-27 19:35:44 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-27 19:35:44 -0700 |
| commit | 578e68047736167239c52fa1aba0347011ff1bc3 (patch) | |
| tree | 00dfacbcaf5bcc846757d37cbf7e9309df699cb8 /src/libstd/iterator.rs | |
| parent | 32117132bdaf572bd4a156ec931579646e16d6f0 (diff) | |
| parent | aac9d6eee9a1e0b254bf6e035e2e14e5106758bd (diff) | |
| download | rust-578e68047736167239c52fa1aba0347011ff1bc3.tar.gz rust-578e68047736167239c52fa1aba0347011ff1bc3.zip | |
auto merge of #8802 : pcwalton/rust/compile-speed, r=brson
r? @brson
Diffstat (limited to 'src/libstd/iterator.rs')
| -rw-r--r-- | src/libstd/iterator.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index 1af49ecd208..4af7b3e2425 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -660,7 +660,10 @@ pub trait AdditiveIterator<A> { impl<A: Add<A, A> + Zero, T: Iterator<A>> AdditiveIterator<A> for T { #[inline] - fn sum(&mut self) -> A { self.fold(Zero::zero::<A>(), |s, x| s + x) } + fn sum(&mut self) -> A { + let zero: A = Zero::zero(); + self.fold(zero, |s, x| s + x) + } } /// A trait for iterators over elements whose elements can be multiplied @@ -685,7 +688,10 @@ pub trait MultiplicativeIterator<A> { impl<A: Mul<A, A> + One, T: Iterator<A>> MultiplicativeIterator<A> for T { #[inline] - fn product(&mut self) -> A { self.fold(One::one::<A>(), |p, x| p * x) } + fn product(&mut self) -> A { + let one: A = One::one(); + self.fold(one, |p, x| p * x) + } } /// A trait for iterators over elements which can be compared to one another. |
