From 58b312a6782389d9bf783710925ef393cfcffafb Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Wed, 5 Jun 2019 14:01:56 -0300 Subject: [PATCH] Testing if Serde create groups --- toml-groups/Cargo.toml | 10 ++++++++++ toml-groups/src/main.rs | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 toml-groups/Cargo.toml create mode 100644 toml-groups/src/main.rs diff --git a/toml-groups/Cargo.toml b/toml-groups/Cargo.toml new file mode 100644 index 0000000..5fb966b --- /dev/null +++ b/toml-groups/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "toml-groups" +version = "0.1.0" +authors = ["Julio Biason "] +edition = "2018" + +[dependencies] +serde = "*" +serde_derive = "*" +toml = "0.5" diff --git a/toml-groups/src/main.rs b/toml-groups/src/main.rs new file mode 100644 index 0000000..e5cce9d --- /dev/null +++ b/toml-groups/src/main.rs @@ -0,0 +1,21 @@ +use serde_derive::Serialize; +use serde_derive::Deserialize; + +#[derive(Serialize, Deserialize)] +struct Child { + name: String, +} + +#[derive(Serialize, Deserialize)] +struct Main { + context: String, + child: Child, +} + +fn main() { + let example = Main { context: "Main".to_string(), + child: Child { name: "child".to_string() } }; + let content = toml::to_string(&example).unwrap(); + + println!("{:?}", content); +}