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.

Object Safety§

This trait is not object safe.

Implementors§