[][src]Macro static_assertions::assert_eq_size_ptr

macro_rules! assert_eq_size_ptr {
    ($x:expr, $($xs:expr),+ $(,)*) => { ... };
}

Asserts that values pointed to are equal in size.

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

Examples

fn operation(x: &(u32, u32), y: &[u16; 4]) {
    assert_eq_size_ptr!(x, y);
}

Byte arrays of different lengths have different sizes:

This example deliberately fails to compile
static BYTES: &[u8; 4] = &[
    /* ... */
];

static TABLE: &[u8; 16] = &[
    /* ... */
];

assert_eq_size_ptr!(BYTES, TABLE);