Advertisement
Guest User

nic

a guest
Jul 10th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.37 KB | None | 0 0
  1. trait Tuple {
  2.     type First;
  3.     type Second;
  4. }
  5.  
  6. impl<T, U> Tuple for (T, U) {
  7.     type First = T;
  8.     type Second = U;
  9. }
  10.  
  11. trait Cast: Tuple {
  12.     fn cast(from: Self::First) -> Self::Second;
  13. }
  14.  
  15. impl Cast for (u32, u64) {
  16.     fn cast(from: u32) -> u64 {
  17.         from as u64
  18.     }
  19. }
  20.  
  21. fn main() {
  22.     let i: u32 = 6;
  23.     println!("{}", Cast::cast(i));
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement