Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created March 14, 2018 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/ee064bdada4b39ea7a8fb944abe60121 to your computer and use it in GitHub Desktop.
Save rust-play/ee064bdada4b39ea7a8fb944abe60121 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
#![feature(specialization)]
trait Foo<T: DefaultFooBehavior> {
fn bar() {
T::do_stuff();
}
}
trait DefaultFooBehavior {
fn do_stuff();
}
impl<T> DefaultFooBehavior for T {
default fn do_stuff() {}
}
struct Baz;
impl DefaultFooBehavior for Baz {
fn do_stuff() { println!("wooooooo!") }
}
fn main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment