mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Delete Decoder::read_map
This commit is contained in:
parent
42904b0219
commit
c6ad61a1bd
@ -81,15 +81,14 @@ where
|
|||||||
V: Decodable<D>,
|
V: Decodable<D>,
|
||||||
{
|
{
|
||||||
fn decode(d: &mut D) -> BTreeMap<K, V> {
|
fn decode(d: &mut D) -> BTreeMap<K, V> {
|
||||||
d.read_map(|d, len| {
|
let len = d.read_usize();
|
||||||
let mut map = BTreeMap::new();
|
let mut map = BTreeMap::new();
|
||||||
for _ in 0..len {
|
for _ in 0..len {
|
||||||
let key = Decodable::decode(d);
|
let key = Decodable::decode(d);
|
||||||
let val = Decodable::decode(d);
|
let val = Decodable::decode(d);
|
||||||
map.insert(key, val);
|
map.insert(key, val);
|
||||||
}
|
}
|
||||||
map
|
map
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,16 +144,15 @@ where
|
|||||||
S: BuildHasher + Default,
|
S: BuildHasher + Default,
|
||||||
{
|
{
|
||||||
fn decode(d: &mut D) -> HashMap<K, V, S> {
|
fn decode(d: &mut D) -> HashMap<K, V, S> {
|
||||||
d.read_map(|d, len| {
|
let len = d.read_usize();
|
||||||
let state = Default::default();
|
let state = Default::default();
|
||||||
let mut map = HashMap::with_capacity_and_hasher(len, state);
|
let mut map = HashMap::with_capacity_and_hasher(len, state);
|
||||||
for _ in 0..len {
|
for _ in 0..len {
|
||||||
let key = Decodable::decode(d);
|
let key = Decodable::decode(d);
|
||||||
let val = Decodable::decode(d);
|
let val = Decodable::decode(d);
|
||||||
map.insert(key, val);
|
map.insert(key, val);
|
||||||
}
|
}
|
||||||
map
|
map
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,16 +221,15 @@ where
|
|||||||
S: BuildHasher + Default,
|
S: BuildHasher + Default,
|
||||||
{
|
{
|
||||||
fn decode(d: &mut D) -> indexmap::IndexMap<K, V, S> {
|
fn decode(d: &mut D) -> indexmap::IndexMap<K, V, S> {
|
||||||
d.read_map(|d, len| {
|
let len = d.read_usize();
|
||||||
let state = Default::default();
|
let state = Default::default();
|
||||||
let mut map = indexmap::IndexMap::with_capacity_and_hasher(len, state);
|
let mut map = indexmap::IndexMap::with_capacity_and_hasher(len, state);
|
||||||
for _ in 0..len {
|
for _ in 0..len {
|
||||||
let key = Decodable::decode(d);
|
let key = Decodable::decode(d);
|
||||||
let val = Decodable::decode(d);
|
let val = Decodable::decode(d);
|
||||||
map.insert(key, val);
|
map.insert(key, val);
|
||||||
}
|
}
|
||||||
map
|
map
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,14 +200,6 @@ pub trait Decoder {
|
|||||||
fn read_char(&mut self) -> char;
|
fn read_char(&mut self) -> char;
|
||||||
fn read_str(&mut self) -> Cow<'_, str>;
|
fn read_str(&mut self) -> Cow<'_, str>;
|
||||||
fn read_raw_bytes_into(&mut self, s: &mut [u8]);
|
fn read_raw_bytes_into(&mut self, s: &mut [u8]);
|
||||||
|
|
||||||
fn read_map<T, F>(&mut self, f: F) -> T
|
|
||||||
where
|
|
||||||
F: FnOnce(&mut Self, usize) -> T,
|
|
||||||
{
|
|
||||||
let len = self.read_usize();
|
|
||||||
f(self, len)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait for types that can be serialized
|
/// Trait for types that can be serialized
|
||||||
|
Loading…
Reference in New Issue
Block a user