Skip to main content

assert_size

Attribute Macro assert_size 

Source
#[assert_size]
Expand description

Attribute macro that causes a compile-time error if the struct’s size_of is not exactly N bytes.

Useful for locking down a struct’s total size against accidental growth.

§Example

#[padlock::assert_size(64)]
struct CacheLine {
    data: [u8; 64],
}