Skip to content

Instantly share code, notes, and snippets.

@ryos36
Created October 8, 2018 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryos36/09b4b54dce7c6eefcbf380981f5b4ca4 to your computer and use it in GitHub Desktop.
Save ryos36/09b4b54dce7c6eefcbf380981f5b4ca4 to your computer and use it in GitHub Desktop.
#[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