Asserts that types are equal in size.
When performing operations such as pointer casts or dealing with
u32, the size of your types matter. That is where
this macro comes into play.
There also exists
assert_eq_size_ptr. Instead of specifying
types to compare, values' sizes can be directly compared against each other.
These three types, despite being very different, all have the same size:
assert_eq_size!([u8; 4], (u16, u16), u32);
The following example fails to compile because
u32 has 4 times the size of
ⓘThis example deliberately fails to compile