@@ -109,6 +109,9 @@ this can be replaced by ``funk.Contains``:
109
109
110
110
// slice of Foo ptr
111
111
funk.Contains([]*Foo{f}, f) // true
112
+ funk.Contains([]*Foo{f}, func (foo *Foo) bool {
113
+ return foo.ID == f.ID
114
+ }) // true
112
115
funk.Contains([]*Foo{f}, nil) // false
113
116
114
117
b := &Foo{
@@ -126,6 +129,9 @@ this can be replaced by ``funk.Contains``:
126
129
127
130
// even map
128
131
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
129
135
130
136
see also, typesafe implementations: ContainsInt _, ContainsInt64 _, ContainsFloat32 _, ContainsFloat64 _, ContainsString _
131
137
@@ -175,6 +181,9 @@ if the value cannot be found.
175
181
176
182
// slice of string
177
183
funk.IndexOf([]string{"foo", "bar"}, "bar") // 1
184
+ funk.IndexOf([]string{"foo", "bar"}, func(value string) bool {
185
+ return value == "bar"
186
+ }) // 1
178
187
funk.IndexOf([]string{"foo", "bar"}, "gilles") // -1
179
188
180
189
see also, typesafe implementations: IndexOfInt _, IndexOfInt64 _, IndexOfFloat32 _, IndexOfFloat64 _, IndexOfString _
@@ -195,6 +204,9 @@ if the value cannot be found.
195
204
196
205
// slice of string
197
206
funk.LastIndexOf([]string{"foo", "bar", "bar"}, "bar") // 2
207
+ funk.LastIndexOf([]string{"foo", "bar"}, func(value string) bool {
208
+ return value == "bar"
209
+ }) // 2
198
210
funk.LastIndexOf([]string{"foo", "bar"}, "gilles") // -1
199
211
200
212
see also, typesafe implementations: LastIndexOfInt _, LastIndexOfInt64 _, LastIndexOfFloat32 _, LastIndexOfFloat64 _, LastIndexOfString _
0 commit comments