Why would I be getting this error message?
Last active
August 29, 2015 14:02
-
-
Save brianloveswords/2c00b21cb82a3e8cd6c4 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
extern crate debug; | |
struct Point { | |
x: f64, | |
y: f64 | |
} | |
enum Shape { | |
Circle(Point, f64), | |
Rectangle(Point, Point) | |
} | |
impl Shape { | |
fn draw(&self) { | |
match *self { | |
Circle(p, f) => draw_circle(p, f), | |
Rectangle(p1, p2) => draw_rectangle(p1, p2) | |
} | |
} | |
} | |
fn draw_circle(point: Point, radius: f64) -> () { | |
println!("Drawing a circle: point {:?}, radius {}", point, radius); | |
} | |
fn draw_rectangle(p1: Point, p2: Point) -> () { | |
println!("Drawing a rectangle: p1 {:?}, p2 {:?}", p1, p2); | |
} | |
fn main() { | |
let s = Circle(Point { x: 1.0, y: 2.0 }, 3.0); | |
let r = Rectangle( | |
Point { x: 10.0, y: 10.0 }, | |
Point { x: 0.0, y: 0.0 } | |
); | |
r.draw(); | |
s.draw(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment