offset
Function parameters
Parameters
This is useful for saving memory when allocating an object that has many
Functions
- TrailerFlags
- This is useful for saving memory when allocating an object that has many
Source
Implementation
pub fn offset(self: Self, comptime field: FieldEnum) usize {
var off: usize = 0;
inline for (@typeInfo(Fields).@"struct".fields, 0..) |field_info, i| {
const active = (self.bits & (1 << i)) != 0;
if (i == @intFromEnum(field)) {
assert(active);
return mem.alignForward(usize, off, @alignOf(field_info.type));
} else if (active) {
off = mem.alignForward(usize, off, @alignOf(field_info.type));
off += @sizeOf(field_info.type);
}
}
}