Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Tuple {
- type First;
- type Second;
- }
- impl<T, U> Tuple for (T, U) {
- type First = T;
- type Second = U;
- }
- trait Cast: Tuple {
- fn cast(from: Self::First) -> Self::Second;
- }
- impl Cast for (u32, u64) {
- fn cast(from: u32) -> u64 {
- from as u64
- }
- }
- fn main() {
- let i: u32 = 6;
- println!("{}", Cast::cast(i));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement