Crates.io | yaml_extras |
lib.rs | yaml_extras |
version | 0.2.0 |
source | src |
created_at | 2023-08-24 01:33:04.250539 |
updated_at | 2023-08-31 23:31:24.04338 |
description | Misc yaml-related utility functions |
homepage | |
repository | https://github.com/lise-henry/yaml_restructure_dots |
max_upload_size | |
id | 953172 |
size | 51,535 |
Misc yaml-related utility functions.
If you use YAML for a configuration file, you might want to allow to use both things like:
compiler:
command: cargo build
and:
compiler.command: cargo build
(Or not. I know I needed that. Whatever.)
The functions restructure_map
and restructure_from_str
allow just that,
converting dotted keys to inner fiels:
let s1 = r#"
compiler:
command: cargo build
"#;
let s2 = r#"
compiler.command: cargo build
"#;
let v1: serde_yaml::Value = serde_yaml::from_str(s1).unwrap();
let v2 = yaml_extras::restructure_from_str(&s2, true).unwrap();
assert_eq!(v1, v2);
License: MPL-2.0