Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. trait T<T> {
  2. fn test(t: T) -> bool;
  3. }
  4.  
  5. struct Test;
  6.  
  7. impl T<i32> for Test {
  8. fn test(t: i32) -> bool {
  9. println!("i32 impl!");
  10. t % 2 == 0
  11. }
  12. }
  13.  
  14. impl T<bool> for Test {
  15. fn test(t: bool) -> bool {
  16. println!("bool impl!");
  17. t
  18. }
  19. }
  20.  
  21.  
  22. fn main() {
  23. let t1 = Test::test(2);
  24. let t2 = Test::test(false);
  25. println!("{T1}, {T2}", T1 = t1, T2 = t2)
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement