Struct std::collections::hash_map::RandomState
pub struct RandomState { /* fields omitted */ }
RandomState
is the default state for HashMap
types.
A particular instance RandomState
will create the same instances of Hasher
, but the hashers created by two different RandomState
instances are unlikely to produce the same result for the same values.
Examples
use std::collections::HashMap; use std::collections::hash_map::RandomState; let s = RandomState::new(); let mut map = HashMap::with_hasher(s); map.insert(1, 2);
Implementations
impl RandomState
pub fn new() -> RandomState
Constructs a new RandomState
that is initialized with random keys.
Examples
use std::collections::hash_map::RandomState; let s = RandomState::new();
Trait Implementations
impl BuildHasher for RandomState
type Hasher = DefaultHasher
Type of the hasher that will be created.
fn build_hasher(&self) -> DefaultHasher
Creates a new hasher. Read more
Calculates the hash of a single value. Read more
impl Clone for RandomState
fn clone(&self) -> RandomState
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for RandomState
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the given formatter. Read more
impl Default for RandomState
fn default() -> RandomState
Constructs a new RandomState
.
Auto Trait Implementations
impl RefUnwindSafe for RandomState
impl Send for RandomState
impl Sync for RandomState
impl Unpin for RandomState
impl UnwindSafe for RandomState
Blanket Implementations
impl<T> From<T> for T
pub fn from(t: T) -> T
Performs the conversion.
pub fn into(self) -> U
Performs the conversion.
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
#41263)recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
Performs the conversion.
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
Performs the conversion.
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/collections/hash_map/struct.RandomState.html