Fix JsonHeaderParser::serialize()

This commit is contained in:
Matthias Beyer 2015-12-02 11:54:37 +01:00
parent 7549db4ffc
commit 2bab3d48e6

View file

@ -103,12 +103,21 @@ impl Serialize for FileHeaderData {
&FileHeaderData::Float(ref f) => f.serialize(ser), &FileHeaderData::Float(ref f) => f.serialize(ser),
&FileHeaderData::Text(ref s) => (&s[..]).serialize(ser), &FileHeaderData::Text(ref s) => (&s[..]).serialize(ser),
&FileHeaderData::Array{values: ref vs} => vs.serialize(ser), &FileHeaderData::Array{values: ref vs} => vs.serialize(ser),
&FileHeaderData::Map{keys: ref ks} => ks.serialize(ser), &FileHeaderData::Map{keys: ref ks} => {
&FileHeaderData::Key{name: ref n, value: ref v} => {
let mut hm = HashMap::new(); let mut hm = HashMap::new();
hm.insert(n, v);
for key in ks {
if let &FileHeaderData::Key{name: ref n, value: ref v} = key {
hm.insert(n, v);
} else {
panic!("Not a key: {:?}", key);
}
}
hm.serialize(ser) hm.serialize(ser)
} },
&FileHeaderData::Key{name: ref n, value: ref v} => unreachable!(),
} }
} }