Skip to content

Commit 3c8fae3

Browse files
Add Random state doc
1 parent e7c822c commit 3c8fae3

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
@@ -1666,6 +1666,17 @@ impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
16661666
/// A particular instance `RandomState` will create the same instances of
16671667
/// `Hasher`, but the hashers created by two different `RandomState`
16681668
/// instances are unlikely to produce the same result for the same values.
1669+
///
1670+
/// # Examples
1671+
///
1672+
/// ```
1673+
/// use std::collections::HashMap;
1674+
/// use std::collections::hash_map::RandomState;
1675+
///
1676+
/// let s = RandomState::new();
1677+
/// let mut map = HashMap::with_hasher(s);
1678+
/// map.insert(1, 2);
1679+
/// ```
16691680
#[derive(Clone)]
16701681
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
16711682
pub struct RandomState {
@@ -1675,6 +1686,14 @@ pub struct RandomState {
16751686

16761687
impl RandomState {
16771688
/// Constructs a new `RandomState` that is initialized with random keys.
1689+
///
1690+
/// # Examples
1691+
///
1692+
/// ```
1693+
/// use std::collections::hash_map::RandomState;
1694+
///
1695+
/// let s = RandomState::new();
1696+
/// ```
16781697
#[inline]
16791698
#[allow(deprecated)] // rand
16801699
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]

0 commit comments

Comments
 (0)