Skip to content

Instantly share code, notes, and snippets.

@dbp
Created October 14, 2012 02:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbp/3887084 to your computer and use it in GitHub Desktop.
Save dbp/3887084 to your computer and use it in GitHub Desktop.
impl eq
struct A {n: uint}
impl A: cmp::Eq {
pure fn eq(other: &A) -> bool {
self.n == other.n
}
pure fn ne(other: &A) -> bool {
!self.eq(other)
}
}
fn main() {
let a = A {n: 1};
let b = A {n: 2};
if a == b {
io::println("eq");
} else {
io::println("ne");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment