This was asked 15 hours ago in the thread with the subject line "Go 1.18
beta1: Embedding Type Parameter in struct definition is an error". :-)

See https://golang.org/issue/49030.

On Wed, Dec 15, 2021 at 3:24 AM Leonard Mittmann <leonard.mittm...@gmail.com>
wrote:

> I just learned that type constraints, which are defined as interfaces are
> actually not usable in all the places "normal" interfaces can be used in.
> E.g., why can a constraint interface not be uses as a struct type?
>
> Let's say I have the func `func Smallest[T constraints.Ordered](s []T) T`.
> How do I write a table test for this func? Intuitively one would try to
> store tests like this:
>
> tests := []struct {
>     Arr: []constraints.Ordered
>     Want: constraints.Ordered
> }{...}
>
> But this is not permitted. Am I missing something why this behavior is
> should be considered good? If a type constraint is nothing like an
> interface... okay, but why call it interface then?
>
> --
> 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/53df110e-8f34-490a-9b77-610dacffdbcfn%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/53df110e-8f34-490a-9b77-610dacffdbcfn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD_nd3yd429Tetf1ZZYM9suLhobKwCuEsxijxk_2ofNZ_w%40mail.gmail.com.

Reply via email to