brood icon indicating copy to clipboard operation
brood copied to clipboard

`World::try_reserve()` method.

Open Anders429 opened this issue 3 years ago • 1 comments

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.

Anders429 avatar Dec 06 '22 05:12 Anders429

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 TryReserveError in the standard library as our error (not ideal, as I would rather control the error and not expose the internal implementation detail of "we use Vecs for component storage" as part of the public API).
  • Look at how libraries like hashbrown, who have their own stable TryReserveError, detect and surface this themselves. Perhaps there is a way we can also create our own error from scratch?

Anders429 avatar Apr 22 '23 04:04 Anders429