minimal-yaml
minimal-yaml copied to clipboard
Missing usage examples
As yaml_rust seems unmaintained, I'm considering switching to minimal-yaml. But as a relative newbie to Rust, I have problems figuring out how to access elements in the minimal-yaml representation.
With yaml_rust, I do stuff like this:
let txt = std::fs::read_to_string("src/simple.yml").unwrap();
let docs = YamlLoader::load_from_str(&txt).unwrap();
// Sequence
let steps = docs[0]["recipe"]["steps"].as_vec().unwrap();
for s in steps {
...
}
// Mapping
let globals = docs[0]["recipe"]["globals"].as_hash().unwrap();
let iter = globals.iter();
for (arg, val) in iter {
...
}
With minimal-yaml, I can get as far as:
let txt = std::fs::read_to_string("src/simple.yml").unwrap();
let rep = parse(&txt).unwrap();
// This works as expected
println!("{:?}", rep);
But I cannot figure out how to loop/search the representation with minimal-yaml. To get me started, a few usage examples in the documentation would be very helpful.
// But how can I do this properly?
for r in &rep {
println!("r: {:?}", dd);
}