mirror of
https://github.com/nelsbrock/iter_accumulate.git
synced 2026-08-14 22:16:48 +02:00
update example in accumulate() documentation
This commit is contained in:
+7
-5
@@ -71,12 +71,14 @@ pub trait IterAccumulate: Iterator {
|
|||||||
/// use iter_accumulate::IterAccumulate;
|
/// use iter_accumulate::IterAccumulate;
|
||||||
///
|
///
|
||||||
/// let input = [1, 2, 3, 4, 5];
|
/// let input = [1, 2, 3, 4, 5];
|
||||||
/// let result = input
|
/// let mut iter = input.iter().accumulate(1, |acc, i| acc * i);
|
||||||
/// .into_iter()
|
|
||||||
/// .accumulate(1, |acc, i| acc * i)
|
|
||||||
/// .collect::<Vec<_>>();
|
|
||||||
///
|
///
|
||||||
/// assert_eq!(result, vec![1, 2, 6, 24, 120]);
|
/// assert_eq!(iter.next(), Some(1));
|
||||||
|
/// assert_eq!(iter.next(), Some(2));
|
||||||
|
/// assert_eq!(iter.next(), Some(6));
|
||||||
|
/// assert_eq!(iter.next(), Some(24));
|
||||||
|
/// assert_eq!(iter.next(), Some(120));
|
||||||
|
/// assert_eq!(iter.next(), None);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`fold()`]: Iterator::fold
|
/// [`fold()`]: Iterator::fold
|
||||||
|
|||||||
Reference in New Issue
Block a user