Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. use std::ops::Sub;
  2.  
  3. struct Foo {
  4. value: i32
  5. }
  6.  
  7. trait MuhTrait {
  8. fn traitfn(self, other: Self) -> Self;
  9. }
  10.  
  11. impl MuhTrait for Foo {
  12. fn traitfn(self, other: Self) -> Self {
  13. other.value - self.value
  14. }
  15. }
  16.  
  17. impl<T> Sub<T> for T where T: MuhTrait {
  18. fn sub(self, other: T) -> T {
  19. other.traitfn(self)
  20. }
  21. }
  22.  
  23. fn main() {
  24. println!("Hello, world!");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement