Closed oskgo closed 5 months ago
Hey @oskgo 👋
Thank you for the information and proposal. It is very interesting. Would you mind doing a PR or something at some point? Or is it more like a tracking issue?
You seem to be fine with the change I'm proposing, so I can write up a PR.
It might make sense to have a tracking issue if it can be set up to be notified when Try
stabilizes, but I don't know how to set that up.
fold
andrfold
are APIs for internal iteration, which is sometimes more efficient than external iteration (next
andnext_back
). It is always possible to implement internal iteration in terms of external, which is what the default impl does, but this implementation need not be optimal.Flatten
(which roaring uses) has more efficientfold
andrfold
implementations than the default. Roaring should use the implementations fromFlatten
rather than the default implementations.Ideally you would implement
try_fold
andtry_rfold
as well, but they cannot be implemented until theTry
trait is stabilized (https://github.com/rust-lang/rust/issues/84277).This might apply to other default implementations overridden by
Flatten
as well.