From 14ae29622ed97e48bdb6dfdc2be266cb8546d9d5 Mon Sep 17 00:00:00 2001 From: andig Date: Mon, 19 Feb 2024 19:48:32 +0100 Subject: [PATCH] Simplify IsA() using slices package --- enumer.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/enumer.go b/enumer.go index c234209..79aeb4a 100644 --- a/enumer.go +++ b/enumer.go @@ -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) } `