Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:4637894
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
trait Drawable { fn draw(&self); }
trait Printable { fn print(&self); }
 
impl Circle: Drawable { fn draw(&self) { ... } }
impl Circle: Printable { fn print(&self) { ... } }
// both traits - Printable and Drawable is
// implemented for `Circle`
 
fn draw_all(shapes: &[@(Drawable+Printable)]) { // invalid syntax in Rust
// suppose we need to accept array of object that both
// printable and drowable, for example,
// to print something to
// log if anything goes wrong
for shapes.each |shape| { shape.draw(); }
}
 
let x: @Circle = @new_circle();
 
draw_all([x as (Drawable + Printable)]); // invalid syntx
// also, loocks very wired, by this is
// what i'm looking for
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.