3 ms·
In rust, hashsets are just hashmaps with a zero-sized type as the value, which results in all the extra getting optimized away.
by nynx 5y ago
In rust, hashsets are just hashmaps with a zero-sized type as the value, which results in all the extra getting optimized away.
- BenTheElder 5y agoA zero-sized type + hashmap for sets is also done in Go with a `struct{}`. [1][2] But without generics it must be implemented again for each entry type ... Kubernetes uses a code generator to automate this, but it's a bit kludge. [3] [1]: https://pkg.go.dev/k8s.io/apimachinery/pkg/util/sets#Empty https://pkg.go.dev/k8s.io/apimachinery/pkg/util/sets#Empty [2]: https://dave.cheney.net/2014/03/25/the-empty-struct https://dave.cheney.net/2014/03/25/the-empty-struct [3]: https://github.com/kubernetes/code-generator/blob/master/cmd/set-gen/main.go https://github.com/kubernetes/code-generator/blob/master/cmd...