Simplify IsA() using slices package

This commit is contained in:
andig 2024-02-19 19:48:32 +01:00 committed by GitHub
parent 5a427ab07c
commit 14ae29622e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 6 deletions

View File

@ -40,12 +40,7 @@ func %[1]sStrings() []string {
// [1]: type name
const stringBelongsMethodLoop = `// IsA%[1]s returns "true" if the value is listed in the enum definition. "false" otherwise
func (i %[1]s) IsA%[1]s() bool {
for _, v := range _%[1]sValues {
if i == v {
return true
}
}
return false
return slices.Contains(_%[1]sValues, i)
}
`