@@ -206,7 +206,7 @@ fn test_resize_policy() {
206
206
/// require this behavior you can create your own hashing function using
207
207
/// [BuildHasherDefault](../hash/struct.BuildHasherDefault.html).
208
208
///
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
210
210
/// this can frequently be achieved by using `#[derive(PartialEq, Eq, Hash)]`.
211
211
/// If you implement these yourself, it is important that the following
212
212
/// property holds:
@@ -218,9 +218,9 @@ fn test_resize_policy() {
218
218
/// In other words, if two keys are equal, their hashes must be equal.
219
219
///
220
220
/// 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.
224
224
///
225
225
/// Relevant papers/articles:
226
226
///
@@ -298,8 +298,14 @@ fn test_resize_policy() {
298
298
/// *stat += random_stat_buff();
299
299
/// ```
300
300
///
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
303
309
///
304
310
/// ```
305
311
/// use std::collections::HashMap;
@@ -525,7 +531,7 @@ impl<K, V, S> HashMap<K, V, S>
525
531
}
526
532
527
533
impl < K : Hash + Eq , V > HashMap < K , V , RandomState > {
528
- /// Creates an empty HashMap.
534
+ /// Creates an empty ` HashMap` .
529
535
///
530
536
/// # Examples
531
537
///
@@ -539,7 +545,7 @@ impl<K: Hash + Eq, V> HashMap<K, V, RandomState> {
539
545
Default :: default ( )
540
546
}
541
547
542
- /// Creates an empty hash map with the given initial capacity.
548
+ /// Creates an empty `HashMap` with the given initial capacity.
543
549
///
544
550
/// # Examples
545
551
///
@@ -557,7 +563,7 @@ impl<K: Hash + Eq, V> HashMap<K, V, RandomState> {
557
563
impl < K , V , S > HashMap < K , V , S >
558
564
where K : Eq + Hash , S : BuildHasher
559
565
{
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
561
567
/// keys.
562
568
///
563
569
/// The created map has the default initial capacity.
@@ -587,7 +593,7 @@ impl<K, V, S> HashMap<K, V, S>
587
593
}
588
594
}
589
595
590
- /// Creates an empty HashMap with space for at least `capacity`
596
+ /// Creates an empty ` HashMap` with space for at least `capacity`
591
597
/// elements, using `hasher` to hash the keys.
592
598
///
593
599
/// Warning: `hasher` is normally randomly generated, and
@@ -677,7 +683,7 @@ impl<K, V, S> HashMap<K, V, S>
677
683
/// Resizes the internal vectors to a new capacity. It's your responsibility to:
678
684
/// 1) Make sure the new capacity is enough for all the elements, accounting
679
685
/// 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.
681
687
fn resize ( & mut self , new_capacity : usize ) {
682
688
assert ! ( self . table. size( ) <= new_capacity) ;
683
689
assert ! ( new_capacity. is_power_of_two( ) || new_capacity == 0 ) ;
@@ -1040,9 +1046,12 @@ impl<K, V, S> HashMap<K, V, S>
1040
1046
/// Returns a reference to the value corresponding to the key.
1041
1047
///
1042
1048
/// 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
1044
1050
/// the key type.
1045
1051
///
1052
+ /// [`Eq`]: ../../std/cmp/trait.Eq.html
1053
+ /// [`Hash`]: ../../std/hash/trait.Hash.html
1054
+ ///
1046
1055
/// # Examples
1047
1056
///
1048
1057
/// ```
@@ -1063,9 +1072,12 @@ impl<K, V, S> HashMap<K, V, S>
1063
1072
/// Returns true if the map contains a value for the specified key.
1064
1073
///
1065
1074
/// 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
1067
1076
/// the key type.
1068
1077
///
1078
+ /// [`Eq`]: ../../std/cmp/trait.Eq.html
1079
+ /// [`Hash`]: ../../std/hash/trait.Hash.html
1080
+ ///
1069
1081
/// # Examples
1070
1082
///
1071
1083
/// ```
@@ -1086,9 +1098,12 @@ impl<K, V, S> HashMap<K, V, S>
1086
1098
/// Returns a mutable reference to the value corresponding to the key.
1087
1099
///
1088
1100
/// 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
1090
1102
/// the key type.
1091
1103
///
1104
+ /// [`Eq`]: ../../std/cmp/trait.Eq.html
1105
+ /// [`Hash`]: ../../std/hash/trait.Hash.html
1106
+ ///
1092
1107
/// # Examples
1093
1108
///
1094
1109
/// ```
@@ -1143,9 +1158,12 @@ impl<K, V, S> HashMap<K, V, S>
1143
1158
/// was previously in the map.
1144
1159
///
1145
1160
/// 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
1147
1162
/// the key type.
1148
1163
///
1164
+ /// [`Eq`]: ../../std/cmp/trait.Eq.html
1165
+ /// [`Hash`]: ../../std/hash/trait.Hash.html
1166
+ ///
1149
1167
/// # Examples
1150
1168
///
1151
1169
/// ```
@@ -1904,12 +1922,15 @@ impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
1904
1922
}
1905
1923
}
1906
1924
1907
- /// `RandomState` is the default state for `HashMap` types.
1925
+ /// `RandomState` is the default state for [ `HashMap`] types.
1908
1926
///
1909
1927
/// 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`
1911
1929
/// instances are unlikely to produce the same result for the same values.
1912
1930
///
1931
+ /// [`HashMap`]: struct.HashMap.html
1932
+ /// [`Hasher`]: ../../hash/trait.Hasher.html
1933
+ ///
1913
1934
/// # Examples
1914
1935
///
1915
1936
/// ```
@@ -1980,10 +2001,13 @@ impl BuildHasher for RandomState {
1980
2001
}
1981
2002
}
1982
2003
1983
- /// The default `Hasher` used by `RandomState`.
2004
+ /// The default [ `Hasher`] used by [ `RandomState`] .
1984
2005
///
1985
2006
/// The internal algorithm is not specified, and so it and its hashes should
1986
2007
/// not be relied upon over releases.
2008
+ ///
2009
+ /// [`RandomState`]: struct.RandomState.html
2010
+ /// [`Hasher`]: ../../hash/trait.Hasher.html
1987
2011
#[ unstable( feature = "hashmap_default_hasher" , issue = "0" ) ]
1988
2012
pub struct DefaultHasher ( SipHasher13 ) ;
1989
2013
0 commit comments