Skip to content

Instantly share code, notes, and snippets.

Created March 19, 2016 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/92329f1229a4d65d9751 to your computer and use it in GitHub Desktop.
Save anonymous/92329f1229a4d65d9751 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
trait Schema {
fn eq(&self, other: &Schema) -> bool;
}
impl<'a> PartialEq<&'a Schema> for &'a Schema {
fn eq(&self, other: &&Schema) -> bool {
Schema::eq(*self, *other)
}
}
struct Foo;
impl Schema for Foo {
fn eq(&self, _other: &Schema) -> bool { true }
}
fn main() {
let foo1 = Foo;
let foo2 = Foo;
if &foo1 as &Schema == &foo2 as &Schema {
println!("Hello, world!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment