Created
April 10, 2021 01:06
-
-
Save Lucretiel/6738190bac731f2f7335a28edd7d464d to your computer and use it in GitHub Desktop.
Example code using autodefault
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use autodefault::autodefault; | |
#[derive(Debug, Default)] | |
struct Big1 { | |
a: i32, | |
b: i32, | |
c: i32, | |
d: i32, | |
e: i32, | |
f: i32, | |
g: i32, | |
} | |
#[derive(Debug, Default)] | |
struct Big2 { | |
a: Big1, | |
b: Big1, | |
c: i32, | |
d: i32, | |
} | |
#[autodefault] | |
fn build_big2() -> Big2 { | |
Big2 { | |
a: Big1 { a: 10, b: 10 }, | |
b: Big1 { f: 10, g: 10 }, | |
c: 10, | |
} | |
} | |
fn main() { | |
let big2 = build_big2(); | |
println!("{:#?}", big2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment