Trait opendp::traits::Hashable

source ·
pub trait Hashable: Primitive + Eq + Hash { }
Expand description

The subset of Primitive types that implement Eq and Hash.

Hashable types can be used as HashMap keys and in HashSets.

Examples: u8, u16, u32, u64, u128, i8, i16, i32, i64, i128, usize, bool, String

This trait lists the traits that are implemented for hashable types. Refer to the constituent traits to see proof definitions on methods.

Example

use opendp::traits::Hashable;
use std::collections::HashSet;
fn test_func<T: Hashable>(value: T) {
    // can be debugged, as Hashable inherits all traits from Primitive
    println!("{value:?}");
     
    // can be used in hash sets and in the keys of hashmaps
    let mut hashset = HashSet::new();
    hashset.insert(value);
}

test_func("apple".to_string());

Implementors§

source§

impl<T> Hashable for Twhere T: Primitive + Eq + Hash,