Skip to content

Instantly share code, notes, and snippets.

@Lazin
Created January 25, 2013 19:43
Show Gist options
  • Save Lazin/4637224 to your computer and use it in GitHub Desktop.
Save Lazin/4637224 to your computer and use it in GitHub Desktop.
trait Foo {
fn foo(&self);
}
trait Bar : Foo {} // trait is empty
impl MyStruct : Foo {
fn foo(&self) {
// implementation goes here
}
}
let a = MyStruct { ... };
let b = a as Bar; // compile time error, MyStruct must explicitly impl Bar trait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment