{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreifr55gfikacugoehouu6cmfa6cqjmfmzasm4elnmwcjlxde4twcqa",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mkq6mixvygu2"
},
"path": "/t/could-collections-hypothetically-store-keys-and-values-inline/24195#post_16",
"publishedAt": "2026-04-30T17:05:17.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "Oh interesting, though I do think this is a somewhat different thing.\n\nThis is not a “small map optimization” where if there are few enough key-value pairs, they get stored in the pointers and other stuff you need on the stack anyway (which is what `compact_str` in Rust and “small string optimizations” in C++ do); rather, it specifically reserves space for some number of key-value pairs on the stack.\n\nReserving space on the stack is a different data type which you’re not precluded from creating by guaranteeing that _when you don’t allocate that space_ everything will be stored on the heap,",
"title": "Could collections hypothetically store keys and values inline?"
}