Skip to content

Instantly share code, notes, and snippets.

@Sgeo
Created August 10, 2016 06:48
Show Gist options
  • Save Sgeo/3fd554338218abb0c5954cd681008870 to your computer and use it in GitHub Desktop.
Save Sgeo/3fd554338218abb0c5954cd681008870 to your computer and use it in GitHub Desktop.
#![feature(specialization)]
struct Foo;
struct No;
struct Yes;
trait Bar {
type Result;
}
impl<T> Bar for T {
default type Result = No;
}
impl Bar for Foo {
type Result = Yes;
}
trait Baz {
fn foo(&self) {
println!("Hi");
}
}
impl<T: Bar<Result=Yes>> Baz for T {}
fn main() {
Foo.foo();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment