Skip to content

@Lazin /gist:4637894

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
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.