macro_rules! struct_with_union_into_bytes { ($ty:ident { $($($field:ident).*: $value:expr,)* }) => { ... }; }
Expand description
Initializes the given fields of a struct or union and returns the bytes of the resulting object as a byte array.
struct_with_union_into_bytes
is invoked like so:
ⓘ
union Foo {
a: u8,
b: u16,
}
struct Bar {
a: Foo,
b: u8,
c: u16,
}
struct_with_union_into_bytes!(Bar { a.b: 1, b: 2, c: 3 })
Each named field is initialized with a value whose type must implement
zerocopy::AsBytes
. Any fields which are not explicitly initialized will be left as
all zeroes.