External Publication
Visit Post

`alloc`-only `HashMap`?

Rust Internals [Unofficial] April 8, 2026
Source

We do not even have core::io or alloc::io yet, despite there being massive numbers of crates that depend upon external projects that supply io::{Read,Write} outside std.

Anything that touches randomness sounds vastly more complex. lol

We could've some uninhabited type like

pub enum RandomState { };

or alternatively

pub type DefaultHasher = !;
impl BuildHasher for RandomState {
    type Hasher = !;
    fn build_hasher(&self) -> ! {
        panic!("Instantiated HashMap outside std!")
    }
}

Yet, these merely force you into declaring your randomness source, so the code would be less compatible than simply doing pub type HashMap = getrandom_hashmap::HashMap or whatever. Not great

If I read correctly, getrandom has 14 different target_os options and another 12 features, including many options only accessible through RUSTFLAGs to avoid cargo feature additivity. I doubt std ever supports all those options.

Also, we could even migrate the ecosystem away from std::collections::HashMap and towards some semi-blessed probabilistic data structures project that always uses getrandom everywhere, so morally shrink std but not really.

Discussion in the ATmosphere

Loading comments...