1 //! An example showing off the usage of `Deserialize` to automatically decode
2 //! TOML into a Rust `struct`, with enums.
7 use serde::Deserialize;
9 /// This is what we're going to decode into.
10 #[derive(Debug, Deserialize)]
15 #[serde(rename = "struct")]
21 #[derive(Debug, Deserialize)]
26 Struct { value: i64 },
32 plain_table = { Plain = {} }
33 tuple = { Tuple = { 0 = 123, 1 = true } }
34 struct = { Struct = { value = 123 } }
35 newtype = { NewType = "value" }
38 { Tuple = { 0 = 123, 1 = true } },
39 { NewType = "value" },
40 { Struct = { value = 123 } }
43 let decoded: Config = toml::from_str(toml_str).unwrap();
44 println!("{:#?}", decoded);