mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 10:38:02 +00:00
Change ser::{Seq,Map}Visitor to return an optional exact length
This is necessary for formats that serialize the length in the format stream. Those formats need the exact length, so the iterator-style size_hint has the wrong semantics.
This commit is contained in:
+1
-5
@@ -233,11 +233,7 @@ impl ser::Serializer for Serializer {
|
||||
fn visit_seq<V>(&mut self, mut visitor: V) -> Result<(), ()>
|
||||
where V: ser::SeqVisitor,
|
||||
{
|
||||
let len = match visitor.size_hint() {
|
||||
(_, Some(len)) => len,
|
||||
(len, None) => len,
|
||||
};
|
||||
|
||||
let len = visitor.len().unwrap_or(0);
|
||||
let values = Vec::with_capacity(len);
|
||||
|
||||
self.state.push(State::Array(values));
|
||||
|
||||
Reference in New Issue
Block a user