Skip to content

Commit

Permalink
iterate: better working example
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe-Cholet committed Jan 11, 2024
1 parent e52a648 commit 7ceae14
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<St, F>(initial_value: St, f: F) -> Iterate<St, F>
where
F: FnMut(&St) -> St,
Expand Down

0 comments on commit 7ceae14

Please sign in to comment.