maeqtt/mqtt/types/Utils.go
2021-09-01 22:36:43 +02:00

19 lines
324 B
Go

package types
// Returns 1 if b is true and 0 if false
func BoolToUint(b bool) uint {
if b {
return 1
}
return 0
}
// Reinterprets a slice of bools as a uint
// This method doesn't check for overflow
func BoolsToUint(b ...bool) uint {
var res uint
for i, v := range b {
res += BoolToUint(v) << i
}
return res
}