You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
321 B
18 lines
321 B
package gentools
|
|
|
|
import "strings"
|
|
|
|
func FlagString[T ~uint32](value T, flags []T, names []string) string {
|
|
if value == 0 {
|
|
return "(none)"
|
|
}
|
|
|
|
parts := make([]string, 0, len(flags))
|
|
for i, flag := range flags {
|
|
if value&flag == flag {
|
|
parts = append(parts, names[i])
|
|
}
|
|
}
|
|
|
|
return strings.Join(parts, "|")
|
|
}
|