An empty struct is idiomatic and expected to be used in a Set type. When/if the memory optimization is reintroduced, no code change will be needed to take advantage of it.
Using a bool instead of empty struct also means that there is more way to use it wrong: check the bool instead of if the key exist, set the bool incorrectly, etc...
I would argue using bool hurts readability more.
Even better write/use a simple library that calls things that are sets `Set`.
I also feel like map[T]struct{} communicates its purpose way better than map[T]bool. When I see a bool I expect it to represent a bit of information, I don't see why using it as a placeholder for "nothing" would be more readable than a type that can literally store nothing.
tym0|2 months ago
I would argue using bool hurts readability more.
Even better write/use a simple library that calls things that are sets `Set`.
Joker_vD|2 months ago
frou_dh|2 months ago
ioanaci|2 months ago
rplnt|2 months ago
edit: I may be wrong here