{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreib7ywq4jbeoh3yq44uxz4ecrvknwva67gf622tx2dhv6sqeiy2gi4",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mgteco7hxio2"
  },
  "path": "/t/alloc-only-hashmap/24071#post_1",
  "publishedAt": "2026-03-11T23:13:31.000Z",
  "site": "https://internals.rust-lang.org",
  "textContent": "There have been times when I wanted `HashMap`/`HashSet` in some code which only has `alloc` to work with, but the default `BuildHasher` implementation being `std`-only prevents that from working.\n\nWhat stops us from just moving the type definition to `alloc` and removing the default type parameter there, and providing the default again via a type alias in `std`? I think it's just methods/trait implementations which explicitly call out the `RandomState` argument (which only exists in `std`). These are:\n\n  * `new`/`with_capacity`: I see no reason why we can't allow that for any `S: Default` instead, and this would allow `new` to be const once const traits happen (this also works for the with-allocator equivalents).\n    * I think this shouldn't break existing code type inference since the existing (soon to be re-export) `std` name for it still has the default argument.\n  * `From<[(K, V); N]>`: This can again be made to use `Default` like above, but the possibility of `.into()` into a place which might be generic and relying on it for type inference could cause type inference failures. Definitely at least worth a crater run before committing anything.\n\n\n\nSo I think it might be possible? I'm not an expert on how type inference works so there might be wider fallout than I'm thinking of.",
  "title": "`alloc`-only `HashMap`?"
}