Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created April 10, 2018 20:58
Show Gist options
  • Save rust-play/d6fd500bc56b9f11c7efbe661c2fdd06 to your computer and use it in GitHub Desktop.
Save rust-play/d6fd500bc56b9f11c7efbe661c2fdd06 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
struct Alpha {}
trait Beta {
fn p(&self, z: &Beta) -> bool;
}
trait Gamma: Beta {}
impl Beta for Alpha {
fn p(&self, z: &Beta) -> bool {
true
}
}
impl Gamma for Alpha {}
fn main() {
let x: &Gamma = &Alpha {};
let y: &Beta = x;
println!("{}", x.p(x));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment