pub trait Collapse: Eq {
// Required method
fn collapse(&self) -> u8;
}
Expand description
Trait for types that can be used as Map
keys.
Implementors should try to minimise collisions by making collapse
return a relatively unique value if possible.
But it is not required.
It is automatically implemented for types implementing the Hash
trait.
A simple folding implementation is provided for byte slices here collapse_iter()
.
The default implementation has integer types implement this through the modulo of itself over 256, whereas byte slice types implement it through an XOR fold over itself. It doesn’t matter though, the programmer is free to implement it how she chooses.
Required Methods§
Object Safety§
This trait is not object safe.