Skip to content

Commit 33ad705

Browse files
authored
Rollup merge of rust-lang#34975 - GuillaumeGomez:random_state_doc, r=steveklabnik
Add Random state doc Last part of rust-lang#29348. r? @steveklabnik
2 parents 87cc1b9 + 3c8fae3 commit 33ad705

File tree

1 file changed

+19
-0
lines changed
  • src/libstd/collections/hash

1 file changed

+19
-0
lines changed

src/libstd/collections/hash/map.rs

+19
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,17 @@ impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
16991699
/// A particular instance `RandomState` will create the same instances of
17001700
/// `Hasher`, but the hashers created by two different `RandomState`
17011701
/// instances are unlikely to produce the same result for the same values.
1702+
///
1703+
/// # Examples
1704+
///
1705+
/// ```
1706+
/// use std::collections::HashMap;
1707+
/// use std::collections::hash_map::RandomState;
1708+
///
1709+
/// let s = RandomState::new();
1710+
/// let mut map = HashMap::with_hasher(s);
1711+
/// map.insert(1, 2);
1712+
/// ```
17021713
#[derive(Clone)]
17031714
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
17041715
pub struct RandomState {
@@ -1708,6 +1719,14 @@ pub struct RandomState {
17081719

17091720
impl RandomState {
17101721
/// Constructs a new `RandomState` that is initialized with random keys.
1722+
///
1723+
/// # Examples
1724+
///
1725+
/// ```
1726+
/// use std::collections::hash_map::RandomState;
1727+
///
1728+
/// let s = RandomState::new();
1729+
/// ```
17111730
#[inline]
17121731
#[allow(deprecated)] // rand
17131732
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]

0 commit comments

Comments
 (0)