Collect to slice #71387
Labels
A-collections
Area: `std::collections`
A-iterators
Area: Iterators
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
This is an enhancement suggestion. Beside the current collect() to collection like Vec, Hash, etc, and the future collect to array:
#69985
I find it useful to also collect to a slice when I don't know at compile-time the exact length of the resulting array, but I know an upper bound of its length.
I have adapted the following code from this crate:
https://github.com/kchmck/collect_slice
https://crates.io/crates/collect_slice
This code should be improved and simplified. And as in Issue #69985 we could return a Result<> instead, and remove the asserts.
The text was updated successfully, but these errors were encountered: