File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -1113,16 +1113,22 @@ pub trait Iterator {
1113
1113
Take { iter : self , n : n}
1114
1114
}
1115
1115
1116
- /// An iterator similar to `fold()`, with internal state.
1117
- ///
1118
- /// `scan()` accumulates a final value, similar to [`fold()`], but instead
1119
- /// of passing along an accumulator, it maintains the accumulator internally.
1116
+ /// An iterator adaptor similar to [`fold()`] but different because it holds
1117
+ /// internal state and produces a new iterator.
1120
1118
///
1121
1119
/// [`fold()`]: #method.fold
1122
1120
///
1123
- /// On each iteraton of `scan()`, you can assign to the internal state, and
1124
- /// a mutable reference to the state is passed as the first argument to the
1125
- /// closure, allowing you to modify it on each iteration.
1121
+ /// `scan()` takes two arguments: an initial value which seeds the internal
1122
+ /// state, and a closure with two arguments, the first being a mutable
1123
+ /// reference to the internal state and the second an iterator element.
1124
+ /// The closure can assign to the internal state to share state between
1125
+ /// iterations.
1126
+ ///
1127
+ /// On iteration, the closure will be applied to each element of the
1128
+ /// iterator and the return value from the closure, an [`Option`], is
1129
+ /// yielded by the iterator.
1130
+ ///
1131
+ /// [`Option`]: ../option/enum.Option.html
1126
1132
///
1127
1133
/// # Examples
1128
1134
///
You can’t perform that action at this time.
0 commit comments