1- use self :: Entry :: * ;
2-
31use core:: borrow:: Borrow ;
42use core:: fmt:: { self , Debug } ;
53use core:: hash:: { BuildHasher , Hash , Hasher } ;
@@ -212,8 +210,8 @@ impl<K: Hash + Eq, V> HashMap<K, V, DefaultHashBuilder> {
212210 /// let mut map: HashMap<&str, i32> = HashMap::new();
213211 /// ```
214212 #[ inline]
215- pub fn new ( ) -> HashMap < K , V , DefaultHashBuilder > {
216- Default :: default ( )
213+ pub fn new ( ) -> Self {
214+ Self :: default ( )
217215 }
218216
219217 /// Creates an empty `HashMap` with the specified capacity.
@@ -228,8 +226,8 @@ impl<K: Hash + Eq, V> HashMap<K, V, DefaultHashBuilder> {
228226 /// let mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
229227 /// ```
230228 #[ inline]
231- pub fn with_capacity ( capacity : usize ) -> HashMap < K , V , DefaultHashBuilder > {
232- HashMap :: with_capacity_and_hasher ( capacity, Default :: default ( ) )
229+ pub fn with_capacity ( capacity : usize ) -> Self {
230+ Self :: with_capacity_and_hasher ( capacity, DefaultHashBuilder :: default ( ) )
233231 }
234232}
235233
@@ -259,8 +257,8 @@ where
259257 /// map.insert(1, 2);
260258 /// ```
261259 #[ inline]
262- pub fn with_hasher ( hash_builder : S ) -> HashMap < K , V , S > {
263- HashMap {
260+ pub fn with_hasher ( hash_builder : S ) -> Self {
261+ Self {
264262 hash_builder,
265263 table : RawTable :: new ( ) ,
266264 }
@@ -288,8 +286,8 @@ where
288286 /// map.insert(1, 2);
289287 /// ```
290288 #[ inline]
291- pub fn with_capacity_and_hasher ( capacity : usize , hash_builder : S ) -> HashMap < K , V , S > {
292- HashMap {
289+ pub fn with_capacity_and_hasher ( capacity : usize , hash_builder : S ) -> Self {
290+ Self {
293291 hash_builder,
294292 table : RawTable :: with_capacity ( capacity) ,
295293 }
@@ -1023,7 +1021,7 @@ where
10231021 V : PartialEq ,
10241022 S : BuildHasher ,
10251023{
1026- fn eq ( & self , other : & HashMap < K , V , S > ) -> bool {
1024+ fn eq ( & self , other : & Self ) -> bool {
10271025 if self . len ( ) != other. len ( ) {
10281026 return false ;
10291027 }
@@ -1059,8 +1057,8 @@ where
10591057{
10601058 /// Creates an empty `HashMap<K, V, S>`, with the `Default` value for the hasher.
10611059 #[ inline]
1062- fn default ( ) -> HashMap < K , V , S > {
1063- HashMap :: with_hasher ( Default :: default ( ) )
1060+ fn default ( ) -> Self {
1061+ Self :: with_hasher ( Default :: default ( ) )
10641062 }
10651063}
10661064
@@ -1245,7 +1243,7 @@ pub struct ValuesMut<'a, K: 'a, V: 'a> {
12451243 inner : IterMut < ' a , K , V > ,
12461244}
12471245
1248- /// A builder for computing where in a HashMap a key-value pair would be stored.
1246+ /// A builder for computing where in a [` HashMap`] a key-value pair would be stored.
12491247///
12501248/// See the [`HashMap::raw_entry_mut`] docs for usage examples.
12511249///
@@ -1288,7 +1286,7 @@ pub struct RawVacantEntryMut<'a, K: 'a, V: 'a, S: 'a> {
12881286 hash_builder : & ' a S ,
12891287}
12901288
1291- /// A builder for computing where in a HashMap a key-value pair would be stored.
1289+ /// A builder for computing where in a [` HashMap`] a key-value pair would be stored.
12921290///
12931291/// See the [`HashMap::raw_entry`] docs for usage examples.
12941292///
@@ -1304,6 +1302,7 @@ where
13041302{
13051303 /// Create a `RawEntryMut` from the given key.
13061304 #[ inline]
1305+ #[ allow( clippy:: wrong_self_convention) ]
13071306 pub fn from_key < Q : ?Sized > ( self , k : & Q ) -> RawEntryMut < ' a , K , V , S >
13081307 where
13091308 K : Borrow < Q > ,
@@ -1316,6 +1315,7 @@ where
13161315
13171316 /// Create a `RawEntryMut` from the given key and its hash.
13181317 #[ inline]
1318+ #[ allow( clippy:: wrong_self_convention) ]
13191319 pub fn from_key_hashed_nocheck < Q : ?Sized > ( self , hash : u64 , k : & Q ) -> RawEntryMut < ' a , K , V , S >
13201320 where
13211321 K : Borrow < Q > ,
@@ -1343,6 +1343,7 @@ where
13431343
13441344 /// Create a `RawEntryMut` from the given hash.
13451345 #[ inline]
1346+ #[ allow( clippy:: wrong_self_convention) ]
13461347 pub fn from_hash < F > ( self , hash : u64 , is_match : F ) -> RawEntryMut < ' a , K , V , S >
13471348 where
13481349 for < ' b > F : FnMut ( & ' b K ) -> bool ,
@@ -1357,6 +1358,7 @@ where
13571358{
13581359 /// Access an entry by key.
13591360 #[ inline]
1361+ #[ allow( clippy:: wrong_self_convention) ]
13601362 pub fn from_key < Q : ?Sized > ( self , k : & Q ) -> Option < ( & ' a K , & ' a V ) >
13611363 where
13621364 K : Borrow < Q > ,
@@ -1369,6 +1371,7 @@ where
13691371
13701372 /// Access an entry by a key and its hash.
13711373 #[ inline]
1374+ #[ allow( clippy:: wrong_self_convention) ]
13721375 pub fn from_key_hashed_nocheck < Q : ?Sized > ( self , hash : u64 , k : & Q ) -> Option < ( & ' a K , & ' a V ) >
13731376 where
13741377 K : Borrow < Q > ,
@@ -1393,6 +1396,7 @@ where
13931396
13941397 /// Access an entry by hash.
13951398 #[ inline]
1399+ #[ allow( clippy:: wrong_self_convention) ]
13961400 pub fn from_hash < F > ( self , hash : u64 , is_match : F ) -> Option < ( & ' a K , & ' a V ) >
13971401 where
13981402 F : FnMut ( & K ) -> bool ,
@@ -1614,6 +1618,7 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> {
16141618 /// Sets the value of the entry with the VacantEntry's key,
16151619 /// and returns a mutable reference to it.
16161620 #[ inline]
1621+ #[ allow( clippy:: shadow_unrelated) ]
16171622 pub fn insert_hashed_nocheck ( self , hash : u64 , key : K , value : V ) -> ( & ' a mut K , & ' a mut V )
16181623 where
16191624 K : Hash ,
@@ -1683,8 +1688,8 @@ pub enum Entry<'a, K: 'a, V: 'a, S: 'a> {
16831688impl < ' a , K : ' a + Debug + Eq + Hash , V : ' a + Debug , S : ' a > Debug for Entry < ' a , K , V , S > {
16841689 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
16851690 match * self {
1686- Vacant ( ref v) => f. debug_tuple ( "Entry" ) . field ( v) . finish ( ) ,
1687- Occupied ( ref o) => f. debug_tuple ( "Entry" ) . field ( o) . finish ( ) ,
1691+ Entry :: Vacant ( ref v) => f. debug_tuple ( "Entry" ) . field ( v) . finish ( ) ,
1692+ Entry :: Occupied ( ref o) => f. debug_tuple ( "Entry" ) . field ( o) . finish ( ) ,
16881693 }
16891694 }
16901695}
@@ -2007,8 +2012,8 @@ impl<'a, K, V, S> Entry<'a, K, V, S> {
20072012 S : BuildHasher ,
20082013 {
20092014 match self {
2010- Occupied ( entry) => entry. into_mut ( ) ,
2011- Vacant ( entry) => entry. insert ( default) ,
2015+ Entry :: Occupied ( entry) => entry. into_mut ( ) ,
2016+ Entry :: Vacant ( entry) => entry. insert ( default) ,
20122017 }
20132018 }
20142019
@@ -2034,8 +2039,8 @@ impl<'a, K, V, S> Entry<'a, K, V, S> {
20342039 S : BuildHasher ,
20352040 {
20362041 match self {
2037- Occupied ( entry) => entry. into_mut ( ) ,
2038- Vacant ( entry) => entry. insert ( default ( ) ) ,
2042+ Entry :: Occupied ( entry) => entry. into_mut ( ) ,
2043+ Entry :: Vacant ( entry) => entry. insert ( default ( ) ) ,
20392044 }
20402045 }
20412046
@@ -2052,8 +2057,8 @@ impl<'a, K, V, S> Entry<'a, K, V, S> {
20522057 #[ inline]
20532058 pub fn key ( & self ) -> & K {
20542059 match * self {
2055- Occupied ( ref entry) => entry. key ( ) ,
2056- Vacant ( ref entry) => entry. key ( ) ,
2060+ Entry :: Occupied ( ref entry) => entry. key ( ) ,
2061+ Entry :: Vacant ( ref entry) => entry. key ( ) ,
20572062 }
20582063 }
20592064
@@ -2083,11 +2088,11 @@ impl<'a, K, V, S> Entry<'a, K, V, S> {
20832088 F : FnOnce ( & mut V ) ,
20842089 {
20852090 match self {
2086- Occupied ( mut entry) => {
2091+ Entry :: Occupied ( mut entry) => {
20872092 f ( entry. get_mut ( ) ) ;
2088- Occupied ( entry)
2093+ Entry :: Occupied ( entry)
20892094 }
2090- Vacant ( entry) => Vacant ( entry) ,
2095+ Entry :: Vacant ( entry) => Entry :: Vacant ( entry) ,
20912096 }
20922097 }
20932098}
@@ -2115,8 +2120,8 @@ impl<'a, K, V: Default, S> Entry<'a, K, V, S> {
21152120 S : BuildHasher ,
21162121 {
21172122 match self {
2118- Occupied ( entry) => entry. into_mut ( ) ,
2119- Vacant ( entry) => entry. insert ( Default :: default ( ) ) ,
2123+ Entry :: Occupied ( entry) => entry. into_mut ( ) ,
2124+ Entry :: Vacant ( entry) => entry. insert ( Default :: default ( ) ) ,
21202125 }
21212126 }
21222127}
@@ -2423,9 +2428,9 @@ where
24232428 S : BuildHasher + Default ,
24242429{
24252430 #[ inline]
2426- fn from_iter < T : IntoIterator < Item = ( K , V ) > > ( iter : T ) -> HashMap < K , V , S > {
2431+ fn from_iter < T : IntoIterator < Item = ( K , V ) > > ( iter : T ) -> Self {
24272432 let iter = iter. into_iter ( ) ;
2428- let mut map = HashMap :: with_capacity_and_hasher ( iter. size_hint ( ) . 0 , Default :: default ( ) ) ;
2433+ let mut map = Self :: with_capacity_and_hasher ( iter. size_hint ( ) . 0 , S :: default ( ) ) ;
24292434 for ( k, v) in iter {
24302435 map. insert ( k, v) ;
24312436 }
0 commit comments