Created
December 12, 2018 15:04
-
-
Save rust-play/547742e1c86ca1dc7867540a4bd08a76 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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
/// various ways to init a struct | |
#[derive(Debug)] | |
struct Point { | |
x: i32, | |
y: i32, | |
} | |
fn main() { | |
let pt1 = Point { x: 11, y: 12 }; | |
let (x, y) = (21, 22); | |
let pt2 = Point { x, y }; | |
let pt3 = Point { x: 31, ..pt1 }; | |
println!("val {:?} {:?} {:?}", pt1, pt2, pt3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment