Skip to content

Instantly share code, notes, and snippets.

@tilpner
Created December 31, 2014 18:11
Show Gist options
  • Save tilpner/c14b167b4b10bafbf782 to your computer and use it in GitHub Desktop.
Save tilpner/c14b167b4b10bafbf782 to your computer and use it in GitHub Desktop.
matching.rs
/// How can I elegantly make this work?
/// play.rust-lang.org didn't seem to be able to *share* right now, so I used gist...
#[allow(dead_code)]
trait D {
fn d(&mut self) {}
}
#[deriving(Show)]
struct A;
impl D for A {}
#[deriving(Show)]
struct B;
impl D for B {}
enum C { A(A), B(B), }
impl C {
fn foo(&mut self) {
match *self {
C::A(ref a) => a.d(),
C::B(ref b) => b.d()
}
}
}
fn main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment