-
-
Save vijairaj/1856c4a87b9d386ba12753f42809d914 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