Created
October 19, 2019 01:11
-
-
Save rust-play/214adf5bd15b18ec2d5c63d97ff8ba2c to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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