libcore is designed with zero heap usage in mind. While it’s a good decision overall, it doesn’t take into account cases when you want to work with constrained environment but actually use heap. And, as the other side of the coin, we have no types in
libstd which would ease life of people who interact with C libs with their own allocation interface. Which is a common practice, especially on Windows, due to runtime hell.
libcoreand reexport it in former, like we do with many other types. Please note this doesn’t imply implementing it in
libcore- just have common abstraction always at hand.
- Add lowlevel container types to
libcorewhich explicitly require allocator to be passed to them and don’t fail:
CoreBox<T, A: Alloc>which behaves just like normal box, but is typed with allocator type, requires its instance to be passed in and returns allocation error instead panicking on allocation failure
CoreDynArray<T, A: Alloc>- behaves similar to
Vec, but goes fallible allocation route and requires explicit allocator, just like
CoreBox. Availability of stuff like
try_reallocateis yet to be decided.
The actual design is of course up to discussion. Here I want to discuss general idea.