Created
October 28, 2019 03:05
-
-
Save quake/fa507070c99bad4571ca324dc9e9ec88 to your computer and use it in GitHub Desktop.
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
fn foo(foo: u32) -> u32 { | |
println!("foo {}", foo); | |
foo + 1 | |
} | |
#[derive(Debug)] | |
struct Bar { | |
bar1: u32, | |
bar2: u32, | |
bar3: u32, | |
} | |
impl Default for Bar { | |
fn default() -> Self { | |
Self { | |
bar1: foo(1), | |
bar2: 0, | |
bar3: 0, | |
} | |
} | |
} | |
impl Bar { | |
pub fn with_bar1(bar1: u32) -> Self { | |
Self { | |
bar1, | |
..Default::default() | |
} | |
} | |
} | |
fn main() { | |
let bar = Bar::with_bar1(3); | |
println!("bar {:?}", bar); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment