Could collections hypothetically store keys and values inline?
robofinch:
The data structures in
std::collections, however, do not explicitly document that they never store values (or, if applicable, keys) inline; AFAICT, this is technically "just" an undocumented implementation detail ofstd. Should I start making an RFC requesting this guarantee?
Why would you want to make that guarantee? I could absolutely see the case for HashMap using specialisation in the future to store small keys and values inline. This is not something that is realistic in Rust today given the poor state of specialisation, but a HashMap<u32, u32> could absolutely benefit from inline storage.
Additionally whatever the backing store is, it could get reallocated, so even a guarantee of not inlining doesn't give you address stability.
Discussion in the ATmosphere