Crates.io | merge-struct |
lib.rs | merge-struct |
version | 0.1.0 |
source | src |
created_at | 2022-08-08 15:33:27.351677 |
updated_at | 2022-08-08 15:33:27.351677 |
description | Deep merge for serializable structs |
homepage | |
repository | https://github.com/jondot/merge-struct |
max_upload_size | |
id | 640888 |
size | 9,992 |
This is a Rust library deep merges two serializable structs.
[dependencies]
merge-struct = "0.1.0"
For most recent version see crates.io
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 (c) 2022 @jondot. See LICENSE for further details.