1 unstable release

0.1.0 Jul 11, 2024

#56 in Programming languages

Download history 4823/week @ 2024-07-10 7960/week @ 2024-07-17 7850/week @ 2024-07-24 7907/week @ 2024-07-31 8199/week @ 2024-08-07 7660/week @ 2024-08-14 8381/week @ 2024-08-21 7382/week @ 2024-08-28 8491/week @ 2024-09-04 8525/week @ 2024-09-11 8651/week @ 2024-09-18 8782/week @ 2024-09-25 8377/week @ 2024-10-02 9511/week @ 2024-10-09 9368/week @ 2024-10-16 7914/week @ 2024-10-23

36,278 downloads per month

Apache-2.0 OR MIT

52KB
871 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