Skip to content

Instantly share code, notes, and snippets.

@hsk
Last active August 29, 2015 14:03
Show Gist options
  • Save hsk/42804744cb6b072cdcbb to your computer and use it in GitHub Desktop.
Save hsk/42804744cb6b072cdcbb to your computer and use it in GitHub Desktop.
trait Eq1 {
fn eq1(&self, o: &Self) -> bool;
}
trait Eq2 {
fn eq2(&self, o: &Self) -> bool;
}
struct I {i:int} impls Eq1, Eq2 {
fn eq1(&self, o: &I) -> bool { (*o).i == (*self).i }
fn eq2(&self, o: &I) -> bool { (*o).i == (*self).i }
}
fn main() {
let a = I{i:1};
println!("{}", I{i:1}.eq1(&a))
println!("{}", I{i:1}.eq2(&a))
}
trait Eq1 {
fn eq1(&self, o: &Self) -> bool;
}
trait Eq2 {
fn eq2(&self, o: &Self) -> bool;
}
struct I {i:int}
impl Eq1 for I {
fn eq1(&self, o: &I) -> bool { (*o).i == (*self).i }
}
impl Eq2 for I{
fn eq2(&self, o: &I) -> bool { (*o).i == (*self).i }
}
fn main() {
let a = I{i:1};
println!("{}", I{i:1}.eq1(&a))
println!("{}", I{i:1}.eq2(&a))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment