aboutsummaryrefslogtreecommitdiff
path: root/src/hash.rs
blob: 4c92173f7327d8a872756f58cb377cdbfe6ed3ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
use core::hash::{Hash, Hasher};

#[doc(hidden)]
pub fn hash<V: Hash>(value: &V) -> usize {
    #[cfg(feature = "std")]
    let mut hasher = std::collections::hash_map::DefaultHasher::new();
    #[cfg(not(feature = "std"))]
    let mut hasher = crate::sip::SipHasher13::new();

    Hash::hash(value, &mut hasher);
    Hasher::finish(&hasher) as usize
}