Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
enum Color { cyan, magenta, yellow, black }
impl Eq for Color {
fn eq(&self, other: &Color) -> bool {
match (*self, *other) {
(cyan, cyan) => { true }
(magenta, magenta) => { true }
(yellow, yellow) => { true }
(black, black) => { true }
_ => { false }
}
}
// Rust 0.7 needs this.
fn ne(&self, other: &Color) -> bool { !self.eq(other) }
}
fn main() {
println(fmt!("%?, %?", cyan == yellow, cyan == cyan));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment