Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created October 19, 2019 01:11
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/214adf5bd15b18ec2d5c63d97ff8ba2c to your computer and use it in GitHub Desktop.
Save rust-play/214adf5bd15b18ec2d5c63d97ff8ba2c to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
trait Foo {
fn foo();
}
struct Bar;
impl Foo for Bar {
fn foo() {
println!("From Bar");
}
}
fn generic_foo<T: Foo>() {
T::foo();
}
fn main() {
generic_foo::<Bar>(); // print "From Bar"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment