From 6f798715de3d4bd744116190d14a413445542820 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Thu, 1 Apr 2021 17:03:06 -0700 Subject: Upgrade rust/crates/itertools to 0.10.0 Test: make Change-Id: Ie8b53cb0a96fd9adcbf7f4afa3b966849fc2ff24 --- src/sources.rs | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'src/sources.rs') 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, } @@ -39,7 +39,7 @@ impl fmt::Debug for RepeatCall /// 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(function: F) -> RepeatCall where F: FnMut() -> A { @@ -52,7 +52,7 @@ impl Iterator for RepeatCall type Item = A; #[inline] - fn next(&mut self) -> Option { + fn next(&mut self) -> Option { Some((self.f)()) } @@ -76,22 +76,21 @@ impl Iterator for RepeatCall /// /// 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 Iterator for Unfold type Item = A; #[inline] - fn next(&mut self) -> Option { + fn next(&mut self) -> Option { (self.f)(&mut self.state) } - - #[inline] - fn size_hint(&self) -> (usize, Option) { - // no possible known bounds at this point - (0, None) - } } /// An iterator that infinitely applies function to value and yields results. -- cgit v1.2.3