Add EnumFlags.from

This commit is contained in:
ktkk 2026-07-14 10:13:26 +00:00
parent 5ff7a358f9
commit 39fcd51a7c
5 changed files with 15 additions and 9 deletions

View file

@ -10,6 +10,12 @@ pub fn EnumFlags(comptime E: type) type {
pub const empty: Self = .{ .data = 0 };
pub fn from(mask: BackingInt) Self {
return .{
.mask = mask,
};
}
pub fn contains(self: Self, flag: E) bool {
return (self.mask & @intFromEnum(flag)) != 0;
}