@@ -642,7 +642,7 @@ impl<T> HeaderMap<T> {
642
642
assert ! ( cap <= MAX_SIZE , "header map reserve over max capacity" ) ;
643
643
assert ! ( cap != 0 , "header map reserve overflowed" ) ;
644
644
645
- if self . entries . len ( ) == 0 {
645
+ if self . entries . is_empty ( ) {
646
646
self . mask = cap as Size - 1 ;
647
647
self . indices = vec ! [ Pos :: none( ) ; cap] . into_boxed_slice ( ) ;
648
648
self . entries = Vec :: with_capacity ( usable_capacity ( cap) ) ;
@@ -1082,22 +1082,22 @@ impl<T> HeaderMap<T> {
1082
1082
danger,
1083
1083
Entry :: Vacant ( VacantEntry {
1084
1084
map: self ,
1085
- hash: hash ,
1085
+ hash,
1086
1086
key: key. into( ) ,
1087
- probe: probe ,
1088
- danger: danger ,
1087
+ probe,
1088
+ danger,
1089
1089
} ) ,
1090
1090
Entry :: Occupied ( OccupiedEntry {
1091
1091
map: self ,
1092
1092
index: pos,
1093
- probe: probe ,
1093
+ probe,
1094
1094
} ) ,
1095
1095
Entry :: Vacant ( VacantEntry {
1096
1096
map: self ,
1097
- hash: hash ,
1097
+ hash,
1098
1098
key: key. into( ) ,
1099
- probe: probe ,
1100
- danger: danger ,
1099
+ probe,
1100
+ danger,
1101
1101
} )
1102
1102
)
1103
1103
}
@@ -1201,7 +1201,7 @@ impl<T> HeaderMap<T> {
1201
1201
1202
1202
ValueDrain {
1203
1203
first : Some ( old) ,
1204
- next : next ,
1204
+ next,
1205
1205
lt : PhantomData ,
1206
1206
}
1207
1207
}
@@ -1407,7 +1407,7 @@ impl<T> HeaderMap<T> {
1407
1407
1408
1408
// backward shift deletion in self.indices
1409
1409
// after probe, shift all non-ideally placed indices backward
1410
- if self . entries . len ( ) > 0 {
1410
+ if ! self . entries . is_empty ( ) {
1411
1411
let mut last_probe = probe;
1412
1412
let mut probe = probe + 1 ;
1413
1413
@@ -1454,9 +1454,9 @@ impl<T> HeaderMap<T> {
1454
1454
assert ! ( self . entries. len( ) < MAX_SIZE , "header map at capacity" ) ;
1455
1455
1456
1456
self . entries . push ( Bucket {
1457
- hash : hash ,
1458
- key : key ,
1459
- value : value ,
1457
+ hash,
1458
+ key,
1459
+ value,
1460
1460
links : None ,
1461
1461
} ) ;
1462
1462
}
@@ -1851,7 +1851,7 @@ impl<'a, K, V, T> TryFrom<&'a HashMap<K, V>> for HeaderMap<T>
1851
1851
type Error = Error ;
1852
1852
1853
1853
fn try_from ( c : & ' a HashMap < K , V > ) -> Result < Self , Self :: Error > {
1854
- c. into_iter ( )
1854
+ c. iter ( )
1855
1855
. map ( |( k, v) | -> crate :: Result < ( HeaderName , T ) > {
1856
1856
let name = TryFrom :: try_from ( k) . map_err ( Into :: into) ?;
1857
1857
let value = TryFrom :: try_from ( v) . map_err ( Into :: into) ?;
@@ -2038,7 +2038,7 @@ fn append_value<T>(
2038
2038
Some ( links) => {
2039
2039
let idx = extra. len ( ) ;
2040
2040
extra. push ( ExtraValue {
2041
- value : value ,
2041
+ value,
2042
2042
prev : Link :: Extra ( links. tail ) ,
2043
2043
next : Link :: Entry ( entry_idx) ,
2044
2044
} ) ;
@@ -2050,7 +2050,7 @@ fn append_value<T>(
2050
2050
None => {
2051
2051
let idx = extra. len ( ) ;
2052
2052
extra. push ( ExtraValue {
2053
- value : value ,
2053
+ value,
2054
2054
prev : Link :: Entry ( entry_idx) ,
2055
2055
next : Link :: Entry ( entry_idx) ,
2056
2056
} ) ;
@@ -2422,7 +2422,7 @@ impl<'a, T> VacantEntry<'a, T> {
2422
2422
// Ensure that there is space in the map
2423
2423
let index =
2424
2424
self . map
2425
- . insert_phase_two ( self . key , value. into ( ) , self . hash , self . probe , self . danger ) ;
2425
+ . insert_phase_two ( self . key , value, self . hash , self . probe , self . danger ) ;
2426
2426
2427
2427
& mut self . map . entries [ index] . value
2428
2428
}
@@ -2449,11 +2449,11 @@ impl<'a, T> VacantEntry<'a, T> {
2449
2449
// Ensure that there is space in the map
2450
2450
let index =
2451
2451
self . map
2452
- . insert_phase_two ( self . key , value. into ( ) , self . hash , self . probe , self . danger ) ;
2452
+ . insert_phase_two ( self . key , value, self . hash , self . probe , self . danger ) ;
2453
2453
2454
2454
OccupiedEntry {
2455
2455
map : self . map ,
2456
- index : index ,
2456
+ index,
2457
2457
probe : self . probe ,
2458
2458
}
2459
2459
}
@@ -2863,7 +2863,7 @@ impl<'a, T> OccupiedEntry<'a, T> {
2863
2863
/// assert_eq!("earth", map["host"]);
2864
2864
/// ```
2865
2865
pub fn insert ( & mut self , value : T ) -> T {
2866
- self . map . insert_occupied ( self . index , value. into ( ) )
2866
+ self . map . insert_occupied ( self . index , value)
2867
2867
}
2868
2868
2869
2869
/// Sets the value of the entry.
@@ -2889,7 +2889,7 @@ impl<'a, T> OccupiedEntry<'a, T> {
2889
2889
/// assert_eq!("earth", map["host"]);
2890
2890
/// ```
2891
2891
pub fn insert_mult ( & mut self , value : T ) -> ValueDrain < ' _ , T > {
2892
- self . map . insert_occupied_mult ( self . index , value. into ( ) )
2892
+ self . map . insert_occupied_mult ( self . index , value)
2893
2893
}
2894
2894
2895
2895
/// Insert the value into the entry.
@@ -2916,7 +2916,7 @@ impl<'a, T> OccupiedEntry<'a, T> {
2916
2916
pub fn append ( & mut self , value : T ) {
2917
2917
let idx = self . index ;
2918
2918
let entry = & mut self . map . entries [ idx] ;
2919
- append_value ( idx, entry, & mut self . map . extra_values , value. into ( ) ) ;
2919
+ append_value ( idx, entry, & mut self . map . extra_values , value) ;
2920
2920
}
2921
2921
2922
2922
/// Remove the entry from the map.
@@ -3095,12 +3095,12 @@ impl<'a, T> Iterator for ValueDrain<'a, T> {
3095
3095
// Exactly 1
3096
3096
( & Some ( _) , & None ) => ( 1 , Some ( 1 ) ) ,
3097
3097
// 1 + extras
3098
- ( & Some ( _) , & Some ( ref extras) ) => {
3098
+ ( & Some ( _) , Some ( extras) ) => {
3099
3099
let ( l, u) = extras. size_hint ( ) ;
3100
3100
( l + 1 , u. map ( |u| u + 1 ) )
3101
3101
} ,
3102
3102
// Extras only
3103
- ( & None , & Some ( ref extras) ) => extras. size_hint ( ) ,
3103
+ ( & None , Some ( extras) ) => extras. size_hint ( ) ,
3104
3104
// No more
3105
3105
( & None , & None ) => ( 0 , Some ( 0 ) ) ,
3106
3106
}
@@ -3111,7 +3111,7 @@ impl<'a, T> FusedIterator for ValueDrain<'a, T> {}
3111
3111
3112
3112
impl < ' a , T > Drop for ValueDrain < ' a , T > {
3113
3113
fn drop ( & mut self ) {
3114
- while let Some ( _ ) = self . next ( ) { }
3114
+ for _ in self . by_ref ( ) { }
3115
3115
}
3116
3116
}
3117
3117
@@ -3154,7 +3154,7 @@ impl Pos {
3154
3154
debug_assert ! ( index < MAX_SIZE ) ;
3155
3155
Pos {
3156
3156
index : index as Size ,
3157
- hash : hash ,
3157
+ hash,
3158
3158
}
3159
3159
}
3160
3160
@@ -3418,7 +3418,7 @@ mod as_header_name {
3418
3418
}
3419
3419
3420
3420
fn as_str ( & self ) -> & str {
3421
- <HeaderName >:: as_str ( * self )
3421
+ <HeaderName >:: as_str ( self )
3422
3422
}
3423
3423
}
3424
3424
@@ -3472,7 +3472,7 @@ mod as_header_name {
3472
3472
}
3473
3473
3474
3474
fn as_str ( & self ) -> & str {
3475
- * self
3475
+ self
3476
3476
}
3477
3477
}
3478
3478
0 commit comments