Delete Decoder::read_map_elt_val

This commit is contained in:
Mark Rousskov 2022-02-09 17:44:54 -05:00
parent 025e1b581a
commit 8def096c4d
2 changed files with 3 additions and 11 deletions

View File

@ -82,7 +82,7 @@ fn decode(d: &mut D) -> BTreeMap<K, V> {
let mut map = BTreeMap::new();
for _ in 0..len {
let key = Decodable::decode(d);
let val = d.read_map_elt_val(|d| Decodable::decode(d));
let val = Decodable::decode(d);
map.insert(key, val);
}
map
@ -148,7 +148,7 @@ fn decode(d: &mut D) -> HashMap<K, V, S> {
let mut map = HashMap::with_capacity_and_hasher(len, state);
for _ in 0..len {
let key = Decodable::decode(d);
let val = d.read_map_elt_val(|d| Decodable::decode(d));
let val = Decodable::decode(d);
map.insert(key, val);
}
map
@ -227,7 +227,7 @@ fn decode(d: &mut D) -> indexmap::IndexMap<K, V, S> {
let mut map = indexmap::IndexMap::with_capacity_and_hasher(len, state);
for _ in 0..len {
let key = Decodable::decode(d);
let val = d.read_map_elt_val(|d| Decodable::decode(d));
let val = Decodable::decode(d);
map.insert(key, val);
}
map

View File

@ -225,14 +225,6 @@ fn read_map<T, F>(&mut self, f: F) -> T
let len = self.read_usize();
f(self, len)
}
#[inline]
fn read_map_elt_val<T, F>(&mut self, f: F) -> T
where
F: FnOnce(&mut Self) -> T,
{
f(self)
}
}
/// Trait for types that can be serialized