-
-
Save ryos36/09b4b54dce7c6eefcbf380981f5b4ca4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug, Copy, Clone)] | |
#[repr(packed)] | |
pub struct B { | |
pub flag1: bool, | |
pub flag2: bool, | |
pub flag3: bool, | |
pub flag4: bool, | |
pub flag5: bool, | |
pub flag6: bool, | |
pub flag7: bool, | |
pub flag8: bool, | |
pub pad0: u8, | |
pub pad1: u16, | |
pub pad2: u32 | |
} | |
#[derive(Debug, Copy, Clone)] | |
pub struct S { | |
pub x: u32, | |
pub y: u32, | |
} | |
pub union U { | |
pub s: S, | |
pub both: u64, | |
pub b: B, | |
} | |
impl U { | |
pub fn new(u0:&U) -> U { | |
let v : u64; | |
unsafe { | |
v = u0.both; | |
} | |
U { both: v } | |
} | |
} | |
impl Clone for U { | |
fn clone(&self) -> U { | |
let v : u64; | |
unsafe { | |
v = self.both; | |
} | |
U { both: v } | |
} | |
} | |
/* | |
impl Copy for U { | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment