Macro static_assertions::assert_eq_size_ptr [−][src]
macro_rules! assert_eq_size_ptr { ($x:expr, $($xs:expr),+ $(,)*) => { ... }; }
Expand description
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:
ⓘ
static BYTES: &[u8; 4] = &[ /* ... */ ]; static TABLE: &[u8; 16] = &[ /* ... */ ]; assert_eq_size_ptr!(BYTES, TABLE);