pub trait Translator: Clone + BuildHasher {
type Key: Ord + Hash + Copy;
// Required method
fn transform(&self, key: &[u8]) -> Self::Key;
}Expand description
Translate keys into a new representation (often a smaller one).
§Warning
The output of Translator::transform is often used as a key in a hash table. If the output is not uniformly distributed, the performance of said hash table will degrade substantially.
Required Associated Types§
Sourcetype Key: Ord + Hash + Copy
type Key: Ord + Hash + Copy
The type of the internal representation of keys.
Although Translator is a BuildHasher, the Key type must still implement Hash for
compatibility with any hash table that wraps Translator. We also require Ord for
compatibility with ordered collections.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.