Guest User

Untitled

a guest
Mar 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. use std::{mem, ops};
  2.  
  3. pub struct Point {
  4. pub x: i32,
  5. pub y: i32,
  6. }
  7. impl ops::Deref for Point {
  8. type Target = (i32, i32);
  9. fn deref(&self) -> &(i32, i32) {
  10. unsafe { mem::transmute(self) }
  11. }
  12. }
  13.  
  14. fn main() {
  15. let pt = Point { x: 42, y: -13 };
  16. println!("x: {} y: {}", pt.0, pt.1);
  17. }
Add Comment
Please, Sign In to add comment