Skip to content

Commit

Permalink
Document the field last of CoalesceBy
Browse files Browse the repository at this point in the history
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)`).
  • Loading branch information
Philippe-Cholet committed Nov 13, 2023
1 parent 5fdfb04 commit 845f8f7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/adaptors/coalesce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ where
C: CountItem<I::Item>,
{
iter: I,
/// `last` is `None` while no item have been taken out of `iter` (at definition).
/// Then `last` will be `Some(Some(item))` until `iter` is exhausted,
/// in which case `last` will be `Some(None)`.
last: Option<Option<C::CItem>>,
f: F,
}
Expand Down

0 comments on commit 845f8f7

Please sign in to comment.