Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::{mem, ops};
- pub struct Point {
- pub x: i32,
- pub y: i32,
- }
- impl ops::Deref for Point {
- type Target = (i32, i32);
- fn deref(&self) -> &(i32, i32) {
- unsafe { mem::transmute(self) }
- }
- }
- fn main() {
- let pt = Point { x: 42, y: -13 };
- println!("x: {} y: {}", pt.0, pt.1);
- }
Add Comment
Please, Sign In to add comment