rustc_data_structures::stable_hasher

Trait FromStableHash

Source
pub trait FromStableHash: Sized {
    type Hash;

    // Required method
    fn from(hash: Self::Hash) -> Self;
}
Expand description

Trait for processing the result of the stable hashing operation.

§Example

use rustc_stable_hash::{StableHasher, FromStableHash};

struct Hash128(u128);

impl FromStableHash for Hash128 {
    type Hash = [u64; 2];

    fn from(hash: [u64; 2]) -> Hash128 {
        let upper: u128 = hash[0] as u128;
        let lower: u128 = hash[1] as u128;

        Hash128((upper << 64) | lower)
    }
}

Required Associated Types§

Required Methods§

Source

fn from(hash: Self::Hash) -> Self

Convert the finalized state of a StableHasher and construct an Self containing the processed hash.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§