From cdf12dfa88ab8ba4bf9ef051262bbb17e83205bf Mon Sep 17 00:00:00 2001 From: Philippe-Cholet Date: Mon, 13 Nov 2023 22:08:33 +0100 Subject: [PATCH] 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)`). --- src/adaptors/coalesce.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/adaptors/coalesce.rs b/src/adaptors/coalesce.rs index f3abdef73..21eaa016d 100644 --- a/src/adaptors/coalesce.rs +++ b/src/adaptors/coalesce.rs @@ -10,6 +10,9 @@ where C: CountItem, { 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>, f: F, }