Skip to content

Instantly share code, notes, and snippets.

@nickretallack
Created January 25, 2017 20:55
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 nickretallack/34ae305443d926dabb000c26a2ee5a63 to your computer and use it in GitHub Desktop.
Save nickretallack/34ae305443d926dabb000c26a2ee5a63 to your computer and use it in GitHub Desktop.
#[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));
}
#[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