On Sat, Oct 22, 2022 at 1:40 AM 'Aaron Beitch' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> I have types Foo and Bar. Bar's underlying type is Foo.
>

The underlying type is defined recursively and always either a predeclared
type (int, string…), or a type literal.
The underlying type of Bar is the underlying type of Foo, which is struct {
data []string }. You might try using `~struct{ data []string }`.


> I want a function that takes in pointers to types whose underlying type is
> Foo, but I get a compile error when trying to call this function:
>
>     *Bar does not implement ~*Foo (*Bar missing in ~*main.Foo)
>
> Should this work?
>
> My real use case is around a hash map library. It's implementation is a
> copy of Go's built-in map, but allows the user to control the equal and
> hash function, thus allowing keys of any type rather than just comparable
> types. github.com/aristanetworks/gomap
>
> I would like to provide helper functions
> <https://github.com/aristanetworks/gomap/blob/main/funcs.go> for
> gomap.Map similar to those provided by golang.org/x/exp/maps and for
> those helpers to work on pointers to types whose underlying type is
> gomap.Map.
>
> Thanks,
> Aaron
>
>
> --
> 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/d6c4621a-13d8-4cd2-b777-eef7a200cca2n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/d6c4621a-13d8-4cd2-b777-eef7a200cca2n%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/CAEkBMfGx%2BZ9km4jfXFHHrfTKuSn5Pvx2--FEW6C%3DxfjVu-pUdQ%40mail.gmail.com.

Reply via email to