depends 0.11.0

Ergonomic, performant, incremental computation between arbitrary types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::{hash::Hasher, ops::Deref};

use super::NodeHash;
use crate::NodeRef;

/// A unique number derived from the internal state of a node.
pub trait HashValue {
    /// Either a unique number, or a value detailing that this node cannot be
    /// hashed.
    fn hash_value(&self, hasher: &mut impl Hasher) -> NodeHash;
}

impl<T: HashValue> HashValue for NodeRef<'_, T> {
    fn hash_value(&self, hasher: &mut impl Hasher) -> NodeHash {
        self.deref().hash_value(hasher)
    }
}