atomic-rs
atomic-rs copied to clipboard
Enum can't work as expected.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(align(2))]
pub enum Test {
A,
B(u8),
}
Test::A
maybe is 0x0000 or 0xXX00, so it maybe not equal when transmute to u16.
You're right, enums will not work with this crate. Only types which have no paddings bytes and no invalid values will work. This effectively constraints it to structs with no padding bytes.
#[repr(align(4))]
pub struct Test {
a: u8,
b: u16,
}
Does this struct have paddings bytes?
Yes it does.