macro_rules! offset_of {
    ($parent:path, $field:tt) => { ... };
}
Expand description

Calculates the offset of the specified field from the start of the named struct.

Examples

use memoffset::offset_of;

#[repr(C, packed)]
struct Foo {
    a: u32,
    b: u64,
    c: [u8; 5]
}

fn main() {
    assert_eq!(offset_of!(Foo, a), 0);
    assert_eq!(offset_of!(Foo, b), 4);
}