3 releases

0.1.2 Mar 5, 2025
0.1.1 Dec 10, 2024
0.1.0 Jul 11, 2024

#79 in Programming languages

Download history 11664/week @ 2025-01-30 12049/week @ 2025-02-06 11941/week @ 2025-02-13 36037/week @ 2025-02-20 63439/week @ 2025-02-27 88423/week @ 2025-03-06 88111/week @ 2025-03-13 78380/week @ 2025-03-20 72109/week @ 2025-03-27 82040/week @ 2025-04-03 74418/week @ 2025-04-10 66546/week @ 2025-04-17 79170/week @ 2025-04-24 77138/week @ 2025-05-01 75877/week @ 2025-05-08 69758/week @ 2025-05-15

313,408 downloads per month
Used in 67 crates (5 directly)

Apache-2.0 OR MIT

54KB
902 lines

rustc-stable-hash

crates.io Documentation

A stable hashing algorithm used by rustc: cross-platform, deterministic, not secure.

This crate provides facilities with the StableHasher structure to create stable hashers over unstable hashers by abstracting over them the handling of endian-ness and the target usize/isize bit size difference.

Currently, this crate provides it's own implementation of 128-bit SipHasher: SipHasher128; with StableSipHasher128 for the stable variant.

Usage

use rustc_stable_hash::hashers::{StableSipHasher128, SipHasher128Hash};
use rustc_stable_hash::FromStableHash;
use std::hash::Hasher;

struct Hash128([u64; 2]);
impl FromStableHash for Hash128 {
    type Hash = SipHasher128Hash;

    fn from(SipHasher128Hash(hash): SipHasher128Hash) -> Hash128 {
        Hash128(hash)
    }
}

let mut hasher = StableSipHasher128::new();
hasher.write_usize(0xFA);

let hash: Hash128 = hasher.finish();

No runtime deps

Features