Closed efulmo closed 1 year ago
Hi @efulmo, you're correct in that a Set
can be used with pointers or structs containing pointers as long as the pointer
comparability is what you're actually expecting. When I wrote that doc string I was thinking about our main use case, where it's common to use a .Equal
method for comparing equality of complex structs, where the behavior of pointer comparisons is wrong.
e.g. https://play.golang.com/p/PPD110sXh9h
So yeah, the doc should be tweaked to be more accurate like the README. Would you be willing to open up a PR?
Closed by #74
Documentation for
set.New()
saysIt's a confusing statement. I use
Set
with addresses to a struct that has some pointer fields and it works just fine - it keeps unique pointers in the set. As far I understand from the source code,Set
has no limitations for pointers or structs with pointers, it just may work in unobvious way for unexperienced developers that don't understand difference between address comparison and deep struct comparison.README
explains this aspect better.