diff options
author | Joel Galenson <jgalenson@google.com> | 2021-04-06 16:54:27 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-04-06 16:54:27 +0000 |
commit | 16514b8f2782005df002eb2e0e0cb0e957b6e694 (patch) | |
tree | 70e883bc01ba2b4d8dd07e0347be18a2fbbd2c18 /src/sources.rs | |
parent | b9502874a5f4caa02c9ffb0613e13e18cdbf1258 (diff) | |
parent | e7475af42409e513e29e78847cebaa1dabeb9765 (diff) | |
download | itertools-16514b8f2782005df002eb2e0e0cb0e957b6e694.tar.gz |
Upgrade rust/crates/itertools to 0.10.0 am: 6f798715de am: b1d1cd1ee8 am: e7475af424android-12.1.0_r9android-12.1.0_r8android-12.1.0_r7android-12.1.0_r26android-12.1.0_r25android-12.1.0_r24android-12.1.0_r23android-12.1.0_r22android-12.1.0_r21android-12.1.0_r20android-12.1.0_r19android-12.1.0_r18android-12.1.0_r17android-12.1.0_r16android-12.1.0_r15android-12.1.0_r14android-12.1.0_r13android-12.1.0_r12android-12.1.0_r11android-12.1.0_r10android-12.0.0_r32android-12.0.0_r29android-12.0.0_r28android-12.0.0_r27android-12.0.0_r26android-12.0.0_r21android-12.0.0_r20android-12.0.0_r19android-12.0.0_r18android-12.0.0_r16android12L-devandroid12L-d2-s8-releaseandroid12L-d2-s7-releaseandroid12L-d2-s6-releaseandroid12L-d2-s5-releaseandroid12L-d2-s4-releaseandroid12L-d2-s3-releaseandroid12L-d2-s2-releaseandroid12L-d2-s1-releaseandroid12L-d2-releaseandroid12-qpr3-s7-releaseandroid12-qpr3-s6-releaseandroid12-qpr3-s5-releaseandroid12-qpr3-s4-releaseandroid12-qpr3-s3-releaseandroid12-qpr3-s2-releaseandroid12-qpr3-s1-releaseandroid12-qpr3-releaseandroid12-qpr1-releaseandroid12-qpr1-d-s3-releaseandroid12-qpr1-d-s2-releaseandroid12-qpr1-d-s1-releaseandroid12-qpr1-d-releaseandroid12-dev
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/itertools/+/1662678
Change-Id: Ic90558e20c754158850e38f901c0cefd7a9bc6f3
Diffstat (limited to 'src/sources.rs')
-rw-r--r-- | src/sources.rs | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/sources.rs b/src/sources.rs index 17d9ff9..5bb6afe 100644 --- a/src/sources.rs +++ b/src/sources.rs @@ -7,7 +7,7 @@ use std::mem; /// See [`repeat_call`](../fn.repeat_call.html) for more information. #[derive(Clone)] -#[deprecated(note="Use std repeat_with() instead", since="0.8")] +#[deprecated(note="Use std repeat_with() instead", since="0.8.0")] pub struct RepeatCall<F> { f: F, } @@ -39,7 +39,7 @@ impl<F> fmt::Debug for RepeatCall<F> /// vec![1, 1, 1, 1, 1] /// ); /// ``` -#[deprecated(note="Use std repeat_with() instead", since="0.8")] +#[deprecated(note="Use std repeat_with() instead", since="0.8.0")] pub fn repeat_call<F, A>(function: F) -> RepeatCall<F> where F: FnMut() -> A { @@ -52,7 +52,7 @@ impl<A, F> Iterator for RepeatCall<F> type Item = A; #[inline] - fn next(&mut self) -> Option<A> { + fn next(&mut self) -> Option<Self::Item> { Some((self.f)()) } @@ -76,22 +76,21 @@ impl<A, F> Iterator for RepeatCall<F> /// /// use itertools::unfold; /// -/// let (mut x1, mut x2) = (1u32, 1u32); -/// let mut fibonacci = unfold((), move |_| { +/// let mut fibonacci = unfold((1u32, 1u32), |(x1, x2)| { /// // Attempt to get the next Fibonacci number -/// let next = x1.saturating_add(x2); +/// let next = x1.saturating_add(*x2); /// /// // Shift left: ret <- x1 <- x2 <- next -/// let ret = x1; -/// x1 = x2; -/// x2 = next; +/// let ret = *x1; +/// *x1 = *x2; +/// *x2 = next; /// /// // If addition has saturated at the maximum, we are finished -/// if ret == x1 && ret > 1 { -/// return None; +/// if ret == *x1 && ret > 1 { +/// None +/// } else { +/// Some(ret) /// } -/// -/// Some(ret) /// }); /// /// itertools::assert_equal(fibonacci.by_ref().take(8), @@ -128,15 +127,9 @@ impl<A, St, F> Iterator for Unfold<St, F> type Item = A; #[inline] - fn next(&mut self) -> Option<A> { + fn next(&mut self) -> Option<Self::Item> { (self.f)(&mut self.state) } - - #[inline] - fn size_hint(&self) -> (usize, Option<usize>) { - // no possible known bounds at this point - (0, None) - } } /// An iterator that infinitely applies function to value and yields results. |