You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ByteValued is an unsafe trait and implementing it is tricky with the padding requirement. But I think it can be autoderived.
Basically, a custom derive that does two things:
Emits something like const __ASSERT_SIZES_Foo: [(); mem::size_of::<Foo>()] = [(); mem::size_of::<Field1>() + mem::size_of::<Field2>() + ...] ] ] to assert that there is no padding
Emit some test function that ends up asserting bounds on all subfields.
This might significantly reduce the amount of unsafe needed by crate users.