itertools icon indicating copy to clipboard operation
itertools copied to clipboard

try_fold_while

Open mightyiam opened this issue 1 year ago • 2 comments

I found myself wanting a try_fold_while... Since there fold_while is not in std, I don't suppose it's the right time to RFC try_fold_while in std. So, would it be accepted here?

I haven't gotten into any detail, but I imagine it to be a straightforward combination of try_fold and fold_while.

mightyiam avatar Dec 25 '23 02:12 mightyiam

The Try trait behind try_fold is unstable so we can't specialize them. And I think try_ methods should use Try. We only have one try_ method: try_collect which is in conflict with the unstable std one. An alternative would be fold_while_ok (we have a bunch of _ok methods, I don't know if we want more), or use our process_results (it_res.process_results(|it| it.fold_while(...))) but it doesn't specialize try_fold either so I guess the performance might be unsatisfying.

Philippe-Cholet avatar Dec 25 '23 08:12 Philippe-Cholet

I suppose we wait, then.

mightyiam avatar Dec 25 '23 11:12 mightyiam