alexcrichton requested fitzgen for a review on PR #12505.
alexcrichton opened PR #12505 from alexcrichton:more-fallible-collect to bytecodealliance:main:
This adds a new
TryCollectextension trait towasmtime-corewhich enablesiter.try_collect()to fallibly collect into aVec<T>orBox<[T]>while handling OOM. This is intended to serve as a replacement for thenew_boxed_slice_*helpers in appropriate situations since it more closely matches what Wasmtime likely already does today where we throw.collect()on iterators.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested wasmtime-core-reviewers for a review on PR #12505.
alexcrichton requested wasmtime-fuzz-reviewers for a review on PR #12505.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #12505.
alexcrichton commented on PR #12505:
I noticed this mostly reading over some slice-handling things in https://github.com/bytecodealliance/wasmtime/pull/12500 and I figured it'd be nice to keep the preexisting
.collect()patterns instead of going all the way to thenew_boxed_slice_*functions where possible.
fitzgen submitted PR review.
fitzgen created PR review comment:
Can you add OOM tests for these cases?
fitzgen created PR review comment:
- Not exactly the same as
std::vec::Vec::extend, as it returns an error on allocation failure. We should note that in the docs.- But also, that is a trait method, not an inherent method.
- So should we also define
TryExtendto pair withTryCollectandTryFromIterator?
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Good points yeah, I forgot
Extendwas a trait! I've moved toTryExtendinstead
alexcrichton updated PR #12505.
alexcrichton has enabled auto merge for PR #12505.
alexcrichton updated PR #12505.
alexcrichton added PR #12505 Add fallible try_collect to collections to the merge queue.
alexcrichton merged PR #12505.
alexcrichton removed PR #12505 Add fallible try_collect to collections from the merge queue.
Last updated: Feb 24 2026 at 04:36 UTC