From 7ceae1489ae868c6bbeca2642357730229145b18 Mon Sep 17 00:00:00 2001 From: Philippe-Cholet Date: Thu, 11 Jan 2024 15:18:38 +0100 Subject: [PATCH] `iterate`: better working example --- src/sources.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sources.rs b/src/sources.rs index 6f4003dec..a7f51e52f 100644 --- a/src/sources.rs +++ b/src/sources.rs @@ -177,7 +177,7 @@ where /// ``` /// use itertools::iterate; /// -/// itertools::assert_equal(iterate(1, |&i| i * 3).take(5), vec![1, 3, 9, 27, 81]); +/// itertools::assert_equal(iterate(1, |i| i % 3 + 1).take(5), vec![1, 2, 3, 1, 2]); /// ``` /// /// **Panics** if compute the next value does. @@ -190,7 +190,7 @@ where /// it.next(); // `5 - 10` overflows. /// ``` /// -/// You can alternatively use [`core::iter::successors`]. +/// You can alternatively use [`core::iter::successors`] as it better describes a finite iterator. pub fn iterate(initial_value: St, f: F) -> Iterate where F: FnMut(&St) -> St,