Skip to content
Snippets Groups Projects
Commit 1f3d64cb authored by ko_oler's avatar ko_oler
Browse files

GetByFunc -> GetElemFn

parent 3a9f4271
No related branches found
No related tags found
No related merge requests found
......@@ -104,7 +104,7 @@ func SetFromSlice[T comparable](input []T) []T {
return s
}
func GetByFunc[T any](input []T, f func(v T) bool) T {
func GetElemFn[T any](input []T, f func(v T) bool) T {
var result T
for _, val := range input {
if f(val) {
......
......@@ -155,7 +155,7 @@ func TestSliceToMap(t *testing.T) {
assert.Equal(t, map[string]*KV{"a": {"a", "1"}, "b": {"b", "2"}, "c": {"c", "3"}}, m)
}
func TestGetByFunc(t *testing.T) {
func TestGetElemFn(t *testing.T) {
type test struct {
ID string
}
......@@ -181,7 +181,7 @@ func TestGetByFunc(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := GetByFunc(tt.input, func(v test) bool { return v.ID == tt.id })
got := GetElemFn(tt.input, func(v test) bool { return v.ID == tt.id })
assert.Equalf(t, tt.want, got, "GetByID(%v)", tt.input)
})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment