@@ -109,6 +109,9 @@ this can be replaced by ``funk.Contains``:
109109
110110 // slice of Foo ptr
111111 funk.Contains([]*Foo{f}, f) // true
112+ funk.Contains([]*Foo{f}, func (foo *Foo) bool {
113+ return foo.ID == f.ID
114+ }) // true
112115 funk.Contains([]*Foo{f}, nil) // false
113116
114117 b := &Foo{
@@ -126,6 +129,9 @@ this can be replaced by ``funk.Contains``:
126129
127130 // even map
128131 funk.Contains(map[int]string{1: "Florent"}, 1) // true
132+ funk.Contains(map[int]string{1: "Florent"}, func(key int, name string) bool {
133+ return key == 1 // or `name == "Florent"` for the value type
134+ }) // true
129135
130136 see also, typesafe implementations: ContainsInt _, ContainsInt64 _, ContainsFloat32 _, ContainsFloat64 _, ContainsString _
131137
@@ -175,6 +181,9 @@ if the value cannot be found.
175181
176182 // slice of string
177183 funk.IndexOf([]string{"foo", "bar"}, "bar") // 1
184+ funk.IndexOf([]string{"foo", "bar"}, func(value string) bool {
185+ return value == "bar"
186+ }) // 1
178187 funk.IndexOf([]string{"foo", "bar"}, "gilles") // -1
179188
180189 see also, typesafe implementations: IndexOfInt _, IndexOfInt64 _, IndexOfFloat32 _, IndexOfFloat64 _, IndexOfString _
@@ -195,6 +204,9 @@ if the value cannot be found.
195204
196205 // slice of string
197206 funk.LastIndexOf([]string{"foo", "bar", "bar"}, "bar") // 2
207+ funk.LastIndexOf([]string{"foo", "bar"}, func(value string) bool {
208+ return value == "bar"
209+ }) // 2
198210 funk.LastIndexOf([]string{"foo", "bar"}, "gilles") // -1
199211
200212 see also, typesafe implementations: LastIndexOfInt _, LastIndexOfInt64 _, LastIndexOfFloat32 _, LastIndexOfFloat64 _, LastIndexOfString _
0 commit comments