expression
TOML arrays of tables
Repeated array-of-table headers describe multiple structured elements; a Vec of structs is a natural typed destination. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): 2 review Common mistake: Repeating a normal table header instead of using an array of tables.
Formal Syntax & Structure
rust syntaxrust
[[items]]Working Example
Example Snippetrust
fn main() { #[derive(serde::Deserialize)] struct Task { name: String } #[derive(serde::Deserialize)] struct Config { tasks: Vec<Task> } let c: Config = toml::from_str("[[tasks]]\nname='read'\n[[tasks]]\nname='review'").unwrap(); println!("{} {}", c.tasks.len(), c.tasks[1].name);}