Skip to content

Instantly share code, notes, and snippets.

@lkuper
Created June 27, 2012 18:26
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 lkuper/3005870 to your computer and use it in GitHub Desktop.
Save lkuper/3005870 to your computer and use it in GitHub Desktop.
iface addable { fn plus(n: int) -> int; }
iface subtractable { fn minus(n: int) -> int; }
impl of addable for int {
fn plus(n: int) -> int { self + n }
fn minus(n: int) -> int { self - n }
}
impl of subtractable for int {
fn minus(n: int) -> uint { self - n as uint }
}
fn main() { assert 3.plus(1) == 5.minus(1); } // error: multiple applicable methods in scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment