Created
January 25, 2017 20:55
-
-
Save nickretallack/34ae305443d926dabb000c26a2ee5a63 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
#[derive(Debug)] | |
struct Point { | |
x: f32, | |
y: f32, | |
} | |
#[derive(Debug)] | |
struct Rectangle { | |
p1: Point, | |
p2: Point, | |
} | |
fn square(point: Point, side: f32) -> Rectangle { | |
Rectangle{ p1: point, p2: Point{ x: point.x + side, y: point.y + side} } | |
} | |
fn main() { | |
let point: Point = Point { x: 0.3, y: 0.4 }; | |
println!("Square: {:?}", square(point, 1f32)); | |
} |
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
#[derive(Debug)] | |
struct Point { | |
x: f32, | |
y: f32, | |
} | |
#[derive(Debug)] | |
struct Rectangle { | |
p1: Point, | |
p2: Point, | |
} | |
fn square(point: Point, side: f32) -> Rectangle { | |
Rectangle{ p2: Point{ x: point.x + side, y: point.y + side}, p1: point } | |
} | |
fn main() { | |
let point: Point = Point { x: 0.3, y: 0.4 }; | |
println!("Square: {:?}", square(point, 1f32)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment