Skip to content

Instantly share code, notes, and snippets.

@brianloveswords
Last active August 29, 2015 14:02
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 brianloveswords/2c00b21cb82a3e8cd6c4 to your computer and use it in GitHub Desktop.
Save brianloveswords/2c00b21cb82a3e8cd6c4 to your computer and use it in GitHub Desktop.
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();
}

Why would I be getting this error message?

error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment