Delete Decoder::read_map_elt_key

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

View File

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

View File

@ -226,14 +226,6 @@ fn read_map<T, F>(&mut self, f: F) -> T
f(self, len)
}
#[inline]
fn read_map_elt_key<T, F>(&mut self, f: F) -> T
where
F: FnOnce(&mut Self) -> T,
{
f(self)
}
#[inline]
fn read_map_elt_val<T, F>(&mut self, f: F) -> T
where