Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. struct MyType;
  2.  
  3. trait MyTrait {
  4. fn foo(&self);
  5. }
  6.  
  7. impl<T> MyTrait for T {
  8. fn foo(&self) {
  9. println!("Hello");
  10. }
  11. }
  12.  
  13. //impl !MyTrait for MyType {}
  14.  
  15. fn main() {
  16. let mt = MyType;
  17. let s = "Rust";
  18. mt.foo();
  19. s.foo();
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement