It would be nice if there was a way to check whether or not the set contains something that matches in a more complex way than just equality.
For example:
import mapset "github.com/deckarep/golang-set/v2"
type Thing struct {
name string
size uint64
}
func (t Thing) String() string {
return t.name
}
var (
Thing1 = Thing{"foo", 42}
Thing2 = Thing{"bar", 43}
)
set := mapset.NewSet(Thing1, Thing2)
if set.ContainsMatching(func(t Thing) bool { return t.String() == "foo" }) {
...
}
I'm not sure if ContainsMatching is the best name.