common_traits 0.12.1

Traits to write generic functions on different numeric types, with atomic support, and other features.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// An generalization of [`core::hash::Hasher`] that doesn't force the output to
/// be [`u64`]
pub trait Hasher {
    type Result;
    fn finish(&self) -> Self::Result;
    fn write(&mut self, bytes: &[u8]);
}

/// An hasher that has extra parameters in initalization
pub trait SeedableHasher {
    type Seed;
    fn new(seed: Self::Seed) -> Self;
}

/// The analog of [`core::hash::Hash`] but that uses [`Hash`]
pub trait Hash {
    fn hash<H: Hasher>(&self, state: &mut H);
}