expression

Nested YAML sequences

Indentation describes nested structures; sequence items map naturally to Vec when their types agree. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): garden, kitchen Common mistake: Using inconsistent indentation or assuming every sequence is homogeneous without a type check.

Formal Syntax & Structure

rust syntaxrust
yaml_serde::from_str::<T>(input)

Working Example

Example Snippetrust
fn main() {    #[derive(serde::Deserialize)]    struct Config { labels: Vec<String> }    let c: Config = yaml_serde::from_str("labels:\n  - garden\n  - kitchen\n").unwrap();    println!("{}", c.labels.join(", "));}
Rust Reference