rustc-stable-hash 0.1.2

A stable hashing algorithm used by rustc
Documentation
  • Coverage
  • 86.67%
    13 out of 15 items documented3 out of 3 items with examples
  • Size
  • Source code size: 66.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.8 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • rust-lang/rustc-stable-hash
    6 4 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • michaelwoerister github:rust-lang:compiler rust-lang-owner

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();
OSZAR »