brood
brood copied to clipboard
`World::try_reserve()` method.
Like World::reserve(), but returns an error instead of panicking when the additional allocation is unable to occur.
This is currently blocked on the fact that alloc::collections::TryReserveError's internals are unstable.
Triage: there hasn't been much movement on the tracking issue for try_reserve_kind (https://github.com/rust-lang/rust/issues/48043). It may be worthwhile looking into a way to surface the error ourselves. We could either:
- Just return the
TryReserveErrorin the standard library as our error (not ideal, as I would rather control the error and not expose the internal implementation detail of "we useVecs for component storage" as part of the public API). - Look at how libraries like
hashbrown, who have their own stableTryReserveError, detect and surface this themselves. Perhaps there is a way we can also create our own error from scratch?