Skip to main content

field_offset

Function field_offset 

Source
pub const fn field_offset<F>() -> usize
where F: Field,
🔬This is a nightly-only experimental API. (field_projections #145383)
Expand description

The offset of a field queried by its field representing type.

Returns the offset of the field represented by F. This function essentially does the same as the offset_of intrinsic, but expects the field to be represented by a generic rather than the variant and field indices. This also is a safe intrinsic and can only be evaluated at compile-time, so it should only appear in constants or inline const blocks.

There should be no need to call this intrinsic manually, as its value is used to define Field::OFFSET, which is publicly accessible.