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

Asserts that values pointed to are equal in size.

Examples

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

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

The following example fails to compile because byte arrays of different lengths have different sizes:

static BYTES: &[u8; 4] = &[
    /* ... */
];

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

assert_eq_size_ptr!(BYTES, TABLE);