diff options
| author | bors <bors@rust-lang.org> | 2018-12-17 16:01:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-12-17 16:01:46 +0000 |
| commit | adbfec229ce07ff4b2a7bf2d6dec2d13cb224980 (patch) | |
| tree | bf6d0ae09d9558cffe97c353b2bbb1b221a267d0 /src | |
| parent | 54f3cd6873149a00ae0fb7723f200dccbb4baaa9 (diff) | |
| parent | f0483f76e6feb256abffb060029f57e09c6d4dc0 (diff) | |
| download | rust-adbfec229ce07ff4b2a7bf2d6dec2d13cb224980.tar.gz rust-adbfec229ce07ff4b2a7bf2d6dec2d13cb224980.zip | |
Auto merge of #56904 - sinkuu:cycle_fold, r=bluss
Remove Cycle::try_fold override Fixes #56883
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/iter/mod.rs | 13 | ||||
| -rw-r--r-- | src/libcore/tests/iter.rs | 2 |
2 files changed, 2 insertions, 13 deletions
diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 7b273f7862a..aa23d49672a 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -649,19 +649,6 @@ impl<I> Iterator for Cycle<I> where I: Clone + Iterator { _ => (usize::MAX, None) } } - - #[inline] - fn try_fold<Acc, F, R>(&mut self, init: Acc, mut f: F) -> R where - Self: Sized, F: FnMut(Acc, Self::Item) -> R, R: Try<Ok=Acc> - { - let mut accum = init; - while let Some(x) = self.iter.next() { - accum = f(accum, x)?; - accum = self.iter.try_fold(accum, &mut f)?; - self.iter = self.orig.clone(); - } - Try::from_ok(accum) - } } #[stable(feature = "fused", since = "1.26.0")] diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 4efa0136314..00b4aa4fa2d 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -1003,6 +1003,8 @@ fn test_cycle() { assert_eq!(it.next(), None); assert_eq!(empty::<i32>().cycle().fold(0, |acc, x| acc + x), 0); + + assert_eq!(once(1).cycle().skip(1).take(4).fold(0, |acc, x| acc + x), 4); } #[test] |
