1 unstable release
0.1.0 | Aug 8, 2022 |
---|
#1058 in Encoding
539 downloads per month
Used in 5 crates
10KB
166 lines
Merge Struct
This is a Rust library deep merges two serializable structs.
Dependency
[dependencies]
merge-struct = "0.1.0"
For most recent version see crates.io
Usage
use std::collections::BTreeMap;
use serde_json;
use serde::{Deserialize, Serialize};
use merge_struct::merge;
let left: Data = serde_json::from_str(
r###"
{
"is_root": false,
"entries": {
"/var/log/f2": {
"name":"f2",
"size": 5
}
},
"folders": [
{
"name": "/var/log",
"num_files": 20
}
]
}
"###,
)
.unwrap();
let right: Data = serde_json::from_str(
r###"
{
"folders":[],
"entries": {
"/var/log/f1": {
"name":"f1",
"size": 12
}
}
}
"###,
).unwrap();
let res = merge(&left, &right);
Copyright
Copyright (c) 2022 @jondot. See LICENSE for further details.
Dependencies
~0.5–1MB
~20K SLoC