Are Hash and Hasher outputs guaranteed to be stable between rust versions?

⚓ Rust    📅 2025-07-26    👤 surdeus    👁️ 2      

surdeus

Author of the rapidhash crate here. I'm wondering if it's possible to offer persistent hashing through std::hash::Hasher, so that the hash output is stable between platforms, rust, and crate versions?

The way I read the std::hash::Hash docs infers that the standard library hashing traits are not suitable for persistent hashing. The last breaking change I'm aware of is pre-1.0 though, with the addition of hashing a string suffix byte.

The line in the std::hash::Hash docs "or only rely on Hash and Hasher implementations that provide additional guarantees" is ambiguous to what those guarantees are, and might even be misleading, as I don't think the Hash trait (let alone implementors) can provide enough guarantees for a Hasher implementation to offer it? Even if write_str was stable, my understanding is there are guarantees on the API, but no guarantees the default implementation isn't free to change in future rust versions.

I'd like to be able to give the crate user base a persistent version of RapidHasher for ease of use, but if that's not possible, a clear way to explain why I can't would be helpful. Thank you!

2 posts - 2 participants

Read full topic

🏷️ Rust_feed