mirror of https://github.com/dmarkham/enumer.git
Simplify IsA() using slices package
This commit is contained in:
parent
5a427ab07c
commit
14ae29622e
|
@ -40,12 +40,7 @@ func %[1]sStrings() []string {
|
||||||
// [1]: type name
|
// [1]: type name
|
||||||
const stringBelongsMethodLoop = `// IsA%[1]s returns "true" if the value is listed in the enum definition. "false" otherwise
|
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 {
|
func (i %[1]s) IsA%[1]s() bool {
|
||||||
for _, v := range _%[1]sValues {
|
return slices.Contains(_%[1]sValues, i)
|
||||||
if i == v {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue