SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. trait MyTrait {
  2.     fn foo();
  3. }
  4.  
  5. struct DefaultImpl;
  6. impl MyTrait for DefaultImpl {
  7.     fn foo() {
  8.         println!("foo default");
  9.     }
  10. }
  11.  
  12. struct TestImpl;
  13. impl MyTrait for TestImpl {
  14.     fn foo() {
  15.         println!("foo test");
  16.     }
  17. }
  18.  
  19. fn print_foo<T>()
  20. where
  21.     T: MyTrait,
  22. {
  23.     T::foo();
  24. }
  25.  
  26. fn main() {
  27.     print_foo::<DefaultImpl>();
  28.     print_foo::<TestImpl>();
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top