Created
October 14, 2012 02:50
-
-
Save dbp/3887084 to your computer and use it in GitHub Desktop.
impl eq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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