Skip to content

Commit cdf12df

Browse files
Philippe-Choletjswrenn
authored andcommitted
Document the field last of CoalesceBy
This behavior is not obvious at first glance of `Iterator::next`. In it, after `let init =`, `last` is `Some(None)` in both cases. With `try_fold`, if `iter` is not exhausted then we have `*last = Some(Some(..))` (otherwise it remains `Some(None)`).
1 parent 0ba7fd7 commit cdf12df

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/adaptors/coalesce.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ where
1010
C: CountItem<I::Item>,
1111
{
1212
iter: I,
13+
/// `last` is `None` while no item have been taken out of `iter` (at definition).
14+
/// Then `last` will be `Some(Some(item))` until `iter` is exhausted,
15+
/// in which case `last` will be `Some(None)`.
1316
last: Option<Option<C::CItem>>,
1417
f: F,
1518
}

0 commit comments

Comments
 (0)