Skip to content

Commit c059459

Browse files
author
Jonathan Turner
authored
Rollup merge of #36298 - GuillaumeGomez:hashmap_doc, r=steveklabnik
Add missing urls r? @steveklabnik
2 parents f654719 + dc0e9c0 commit c059459

File tree

1 file changed

+42
-18
lines changed
  • src/libstd/collections/hash

1 file changed

+42
-18
lines changed

src/libstd/collections/hash/map.rs

+42-18
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fn test_resize_policy() {
206206
/// require this behavior you can create your own hashing function using
207207
/// [BuildHasherDefault](../hash/struct.BuildHasherDefault.html).
208208
///
209-
/// It is required that the keys implement the `Eq` and `Hash` traits, although
209+
/// It is required that the keys implement the [`Eq`] and [`Hash`] traits, although
210210
/// this can frequently be achieved by using `#[derive(PartialEq, Eq, Hash)]`.
211211
/// If you implement these yourself, it is important that the following
212212
/// property holds:
@@ -218,9 +218,9 @@ fn test_resize_policy() {
218218
/// In other words, if two keys are equal, their hashes must be equal.
219219
///
220220
/// It is a logic error for a key to be modified in such a way that the key's
221-
/// hash, as determined by the `Hash` trait, or its equality, as determined by
222-
/// the `Eq` trait, changes while it is in the map. This is normally only
223-
/// possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
221+
/// hash, as determined by the [`Hash`] trait, or its equality, as determined by
222+
/// the [`Eq`] trait, changes while it is in the map. This is normally only
223+
/// possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
224224
///
225225
/// Relevant papers/articles:
226226
///
@@ -298,8 +298,14 @@ fn test_resize_policy() {
298298
/// *stat += random_stat_buff();
299299
/// ```
300300
///
301-
/// The easiest way to use `HashMap` with a custom type as key is to derive `Eq` and `Hash`.
302-
/// We must also derive `PartialEq`.
301+
/// The easiest way to use `HashMap` with a custom type as key is to derive [`Eq`] and [`Hash`].
302+
/// We must also derive [`PartialEq`].
303+
///
304+
/// [`Eq`]: ../../std/cmp/trait.Eq.html
305+
/// [`Hash`]: ../../std/hash/trait.Hash.html
306+
/// [`PartialEq`]: ../../std/cmp/trait.PartialEq.html
307+
/// [`RefCell`]: ../../std/cell/struct.RefCell.html
308+
/// [`Cell`]: ../../std/cell/struct.Cell.html
303309
///
304310
/// ```
305311
/// use std::collections::HashMap;
@@ -525,7 +531,7 @@ impl<K, V, S> HashMap<K, V, S>
525531
}
526532

527533
impl<K: Hash + Eq, V> HashMap<K, V, RandomState> {
528-
/// Creates an empty HashMap.
534+
/// Creates an empty `HashMap`.
529535
///
530536
/// # Examples
531537
///
@@ -539,7 +545,7 @@ impl<K: Hash + Eq, V> HashMap<K, V, RandomState> {
539545
Default::default()
540546
}
541547

542-
/// Creates an empty hash map with the given initial capacity.
548+
/// Creates an empty `HashMap` with the given initial capacity.
543549
///
544550
/// # Examples
545551
///
@@ -557,7 +563,7 @@ impl<K: Hash + Eq, V> HashMap<K, V, RandomState> {
557563
impl<K, V, S> HashMap<K, V, S>
558564
where K: Eq + Hash, S: BuildHasher
559565
{
560-
/// Creates an empty hashmap which will use the given hash builder to hash
566+
/// Creates an empty `HashMap` which will use the given hash builder to hash
561567
/// keys.
562568
///
563569
/// The created map has the default initial capacity.
@@ -587,7 +593,7 @@ impl<K, V, S> HashMap<K, V, S>
587593
}
588594
}
589595

590-
/// Creates an empty HashMap with space for at least `capacity`
596+
/// Creates an empty `HashMap` with space for at least `capacity`
591597
/// elements, using `hasher` to hash the keys.
592598
///
593599
/// Warning: `hasher` is normally randomly generated, and
@@ -677,7 +683,7 @@ impl<K, V, S> HashMap<K, V, S>
677683
/// Resizes the internal vectors to a new capacity. It's your responsibility to:
678684
/// 1) Make sure the new capacity is enough for all the elements, accounting
679685
/// for the load factor.
680-
/// 2) Ensure new_capacity is a power of two or zero.
686+
/// 2) Ensure `new_capacity` is a power of two or zero.
681687
fn resize(&mut self, new_capacity: usize) {
682688
assert!(self.table.size() <= new_capacity);
683689
assert!(new_capacity.is_power_of_two() || new_capacity == 0);
@@ -1040,9 +1046,12 @@ impl<K, V, S> HashMap<K, V, S>
10401046
/// Returns a reference to the value corresponding to the key.
10411047
///
10421048
/// The key may be any borrowed form of the map's key type, but
1043-
/// `Hash` and `Eq` on the borrowed form *must* match those for
1049+
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
10441050
/// the key type.
10451051
///
1052+
/// [`Eq`]: ../../std/cmp/trait.Eq.html
1053+
/// [`Hash`]: ../../std/hash/trait.Hash.html
1054+
///
10461055
/// # Examples
10471056
///
10481057
/// ```
@@ -1063,9 +1072,12 @@ impl<K, V, S> HashMap<K, V, S>
10631072
/// Returns true if the map contains a value for the specified key.
10641073
///
10651074
/// The key may be any borrowed form of the map's key type, but
1066-
/// `Hash` and `Eq` on the borrowed form *must* match those for
1075+
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
10671076
/// the key type.
10681077
///
1078+
/// [`Eq`]: ../../std/cmp/trait.Eq.html
1079+
/// [`Hash`]: ../../std/hash/trait.Hash.html
1080+
///
10691081
/// # Examples
10701082
///
10711083
/// ```
@@ -1086,9 +1098,12 @@ impl<K, V, S> HashMap<K, V, S>
10861098
/// Returns a mutable reference to the value corresponding to the key.
10871099
///
10881100
/// The key may be any borrowed form of the map's key type, but
1089-
/// `Hash` and `Eq` on the borrowed form *must* match those for
1101+
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
10901102
/// the key type.
10911103
///
1104+
/// [`Eq`]: ../../std/cmp/trait.Eq.html
1105+
/// [`Hash`]: ../../std/hash/trait.Hash.html
1106+
///
10921107
/// # Examples
10931108
///
10941109
/// ```
@@ -1143,9 +1158,12 @@ impl<K, V, S> HashMap<K, V, S>
11431158
/// was previously in the map.
11441159
///
11451160
/// The key may be any borrowed form of the map's key type, but
1146-
/// `Hash` and `Eq` on the borrowed form *must* match those for
1161+
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
11471162
/// the key type.
11481163
///
1164+
/// [`Eq`]: ../../std/cmp/trait.Eq.html
1165+
/// [`Hash`]: ../../std/hash/trait.Hash.html
1166+
///
11491167
/// # Examples
11501168
///
11511169
/// ```
@@ -1904,12 +1922,15 @@ impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
19041922
}
19051923
}
19061924

1907-
/// `RandomState` is the default state for `HashMap` types.
1925+
/// `RandomState` is the default state for [`HashMap`] types.
19081926
///
19091927
/// A particular instance `RandomState` will create the same instances of
1910-
/// `Hasher`, but the hashers created by two different `RandomState`
1928+
/// [`Hasher`], but the hashers created by two different `RandomState`
19111929
/// instances are unlikely to produce the same result for the same values.
19121930
///
1931+
/// [`HashMap`]: struct.HashMap.html
1932+
/// [`Hasher`]: ../../hash/trait.Hasher.html
1933+
///
19131934
/// # Examples
19141935
///
19151936
/// ```
@@ -1980,10 +2001,13 @@ impl BuildHasher for RandomState {
19802001
}
19812002
}
19822003

1983-
/// The default `Hasher` used by `RandomState`.
2004+
/// The default [`Hasher`] used by [`RandomState`].
19842005
///
19852006
/// The internal algorithm is not specified, and so it and its hashes should
19862007
/// not be relied upon over releases.
2008+
///
2009+
/// [`RandomState`]: struct.RandomState.html
2010+
/// [`Hasher`]: ../../hash/trait.Hasher.html
19872011
#[unstable(feature = "hashmap_default_hasher", issue = "0")]
19882012
pub struct DefaultHasher(SipHasher13);
19892013

0 commit comments

Comments
 (0)