Macro static_assertions::assert_eq_size [] [src]

macro_rules! assert_eq_size {
    ($x:ty, $($xs:ty),+) => { ... };
}

Asserts at compile-time that the types have equal sizes.

This especially is useful for when coercing pointers between different types and ensuring the underlying values are the same size.

Example

struct Byte(u8);

assert_eq_size!(Byte, u8);

// Supports unlimited arguments:
assert_eq_size!([Byte; 4], [u16; 2], u32);

// Fails to compile:
// assert_eq_size!(Byte, u16);