Macro intrusive_collections::offset_of[][src]

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

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

Examples

#[macro_use]
extern crate memoffset;

#[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);
}