Skip to content

Instantly share code, notes, and snippets.

@vijairaj
Forked from rust-play/playground.rs
Created December 12, 2018 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijairaj/1856c4a87b9d386ba12753f42809d914 to your computer and use it in GitHub Desktop.
Save vijairaj/1856c4a87b9d386ba12753f42809d914 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
/// 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