It is not possible and I think it is unlikely to ever happen (though it
might be reasonably implemented as a library at some point).

On Thu, Dec 23, 2021 at 9:42 PM aind...@gmail.com <aindu...@gmail.com>
wrote:

> Now that generics is coming along, is there an easy way to extend the
> builtin map type to use a non-comparable key type? For example, given this
> constraint
>
> type Key[T any] interface {
>         Size() uint64
>         Hash(seed uint64) uint64
>         Equal(T) bool
> }
>
> and a type Foo like
>
> type Foo []int
> func (a Foo) Size() uint64 { ... }
> func (a Foo) Hash(seed uint64) uint64 { ... }
> func (a Foo) Equal(b Foo) bool { ... }
>
> I'd like a map[Foo]struct{}. Is this possible now? Or does the runtime map
> have to be updated to support this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/a9296c66-7715-45ac-9fce-b1d3bc5b4343n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/a9296c66-7715-45ac-9fce-b1d3bc5b4343n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfEQ9NaJB%3DN1OxtZ4p87U-7zkL0B1DemdfoeMNh2kkMsow%40mail.gmail.com.

Reply via email to