Skip to content

Instantly share code, notes, and snippets.

@jmgrosen
Created June 30, 2013 04:50
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 jmgrosen/5893895 to your computer and use it in GitHub Desktop.
Save jmgrosen/5893895 to your computer and use it in GitHub Desktop.
struct Foo {
value: uint
}
impl Sub<Foo, Foo> for Foo {
fn sub(&self, rhs: &Foo) -> Foo {
Foo {value: self.value - rhs.value}
}
}
fn main() {
let mut foo1 = Foo {value: 5};
let foo2 = Foo {value: 2};
foo1 -= foo2;
println(fmt!("%?", foo1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment