Stored as a power-of-two, with one special value to indicate none.
pub const Alignment = enum(u6)
pub const Alignment = enum(u6) {
@"1" = 0,
@"2" = 1,
@"4" = 2,
@"8" = 3,
@"16" = 4,
@"32" = 5,
@"64" = 6,
none = std.math.maxInt(u6),
_,
pub fn init(optional_alignment: ?std.mem.Alignment) @This() {
const a = optional_alignment orelse return .none;
return @fromBackingInt(@intCast(@backingInt(a)));
}
pub fn toBytes(a: @This()) ?u64 {
return switch (a) {
.none => null,
else => @as(u64, 1) << @backingInt(a),
};
}
}