Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait MyTrait {
- fn foo();
- }
- struct DefaultImpl;
- impl MyTrait for DefaultImpl {
- fn foo() {
- println!("foo default");
- }
- }
- struct TestImpl;
- impl MyTrait for TestImpl {
- fn foo() {
- println!("foo test");
- }
- }
- fn print_foo<T>()
- where
- T: MyTrait,
- {
- T::foo();
- }
- fn main() {
- print_foo::<DefaultImpl>();
- print_foo::<TestImpl>();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement