pub struct Field {
pub name: Option<Symbol>,
pub ty: TypeId,
pub offset: u64,
pub bit: u32,
pub align: u64,
pub bits: Option<u32>,
}Expand description
One member of a record, placed.
Fields§
§name: Option<Symbol>The member name, absent for an unnamed bit-field or an anonymous member.
ty: TypeIdThe member type.
offset: u64Where the member starts, in bytes from the start of the record, rounded down.
For an ordinary member this is exactly where it starts. For a bit-field it is the byte the first of its bits lives in, which is a starting point for a load rather than an address the program may take.
Bytes and not bits, with Field::bit holding the rest. A record may be PTRDIFF_MAX
bytes and that many bits is more than a u64 holds, so a single bit offset would make
the largest record this compiler can lay out an eighth of the largest one C allows.
bit: u32Which bit of that byte the member starts at, from zero to seven.
Always zero for an ordinary member, since every one of those starts on a byte boundary.
align: u64What the member’s offset is a multiple of, which is the alignment it was placed at.
The same as the alignment of its type for most members, one byte under packed, and more
than either where aligned asked for more. It is here because it is the only thing known
about where a member sits once the offset stops being a number: an address is as aligned
as the record is and as the offset into it is, and this is that second half.
bits: Option<u32>The bit-field width, absent when the member is an ordinary one.
Implementations§
Source§impl Field
impl Field
Sourcepub fn bit_offset(&self) -> u128
pub fn bit_offset(&self) -> u128
Where the member starts, in bits from the start of the record.
A u128 for the reason Field::offset is bytes. Nothing that generates code wants
this number, which is why it is not what is stored: it is here because the layout rules
were measured in bits and the tests that check them read in bits.
Sourcepub fn is_bit_field(&self) -> bool
pub fn is_bit_field(&self) -> bool
Whether the member is a bit-field, zero width included.