Created
July 26, 2019 19:33
-
-
Save bbengfort/12bf9343313e0211af7566fe2649ac34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Bitmask uint8 | |
const ( | |
F0 bitmask = 1 << iota | |
F1 | |
F2 | |
) | |
func Set(b, flag Bitmask) Bitmask { return b | flag } | |
func Clear(b, flag Bitmask) Bitmask { return b &^ flag } | |
func Toggle(b, flag Bitmask) Bitmask { return b ^ flag } | |
func Has(b, flag Bitmask) bool { return b&flag != 0 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment