You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be interesting to add a next_arrayvec<N> iterator method. It should construct an ArrayVec with capacity N, filling it from the next elements of an iterator. If not enough elements are there to fill it to its capacity, the ArrayVec would retain the remainder of the elements of the iterator instead of error-ing.
This seems more ergonomic to work with than next_array which returns Option<[T;N]> without the ability to access the dropped elements or the standard library's unstable next_chunk which returns Result<[T; N], IntoIter<T>>, where the error is an iterator over the rest of the elements.
It could also be clean API to add a collect_arrayvec which requires an iterator to have at most N elements but potentially less, whereas next_arrayvec<N> makes no requirements on the iterator.
The text was updated successfully, but these errors were encountered:
wmstack
changed the title
Add a next_arrayvec iterator method
Feature Request: next_arrayvec iterator method
Apr 8, 2025
So far we refrained from bringing in arrayvec as a dependency, but @jswrenn I sincerely ask myself if next_arrayvec would actually the superior API. Intuitively, I lean towards "yes": It seems more general, callers can still get their array by using into_inner, and there are no items cut off.
Uh oh!
There was an error while loading. Please reload this page.
It would be interesting to add a
next_arrayvec<N>
iterator method. It should construct an ArrayVec with capacityN
, filling it from the next elements of an iterator. If not enough elements are there to fill it to its capacity, the ArrayVec would retain the remainder of the elements of the iterator instead of error-ing.This seems more ergonomic to work with than
next_array
which returnsOption<[T;N]>
without the ability to access the dropped elements or the standard library's unstablenext_chunk
which returnsResult<[T; N], IntoIter<T>>
, where the error is an iterator over the rest of the elements.It could also be clean API to add a
collect_arrayvec
which requires an iterator to have at mostN
elements but potentially less, whereasnext_arrayvec<N>
makes no requirements on the iterator.The text was updated successfully, but these errors were encountered: