assert-offset 0.1.2

Derive macro for asserting the memory offset of fields in a struct.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use assert_offset::AssertOffsets;

#[derive(AssertOffsets)]
#[repr(C)] //
pub struct Foo {
    // Try reordering these fields or changing their types
    pub a: u8,
    #[offset(0x2)]
    pub b: u16,
}

fn main() {}