Julio Biason
5 years ago
2 changed files with 31 additions and 0 deletions
@ -0,0 +1,10 @@ |
|||||||
|
[package] |
||||||
|
name = "toml-groups" |
||||||
|
version = "0.1.0" |
||||||
|
authors = ["Julio Biason <julio.biason@pm.me>"] |
||||||
|
edition = "2018" |
||||||
|
|
||||||
|
[dependencies] |
||||||
|
serde = "*" |
||||||
|
serde_derive = "*" |
||||||
|
toml = "0.5" |
@ -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); |
||||||
|
} |
Loading…
Reference in new issue