mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-21 18:10:42 -04:00
DEV: Collapse fields when merging yaml maps
This commit is contained in:
parent
949d468f55
commit
4ec27ff426
@ -1,4 +1,5 @@
|
||||
use std;
|
||||
use std::collections::BTreeSet;
|
||||
use std::error::Error;
|
||||
use std::io::Write;
|
||||
use std::rc::Rc;
|
||||
@ -123,7 +124,17 @@ impl YamlConverter {
|
||||
serde_yaml::Value::Mapping(m) => {
|
||||
let mut fs = Vec::with_capacity(m.len());
|
||||
self.merge_mapping_keys(&mut fs, m)?;
|
||||
Val::Tuple(fs)
|
||||
fs.reverse();
|
||||
let mut seen_keys = BTreeSet::new();
|
||||
let mut collapsed = Vec::with_capacity(fs.len());
|
||||
for (k, val) in fs {
|
||||
if !seen_keys.contains(&k) {
|
||||
collapsed.push((k.clone(), val));
|
||||
seen_keys.insert(k);
|
||||
}
|
||||
}
|
||||
collapsed.reverse();
|
||||
Val::Tuple(collapsed)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user