package main

type A interface {
        Ma()
}

type B interface {
        Mb()
}

type Ta struct { A }

type Tb struct { B }

func ConvertSliceToA[From A](vs []From) []A {
        var r = make([]A, len(vs))
        for i := range vs {
                r[i] = vs[i]
        }
        return r
}

func ConvertSliceToB[From B](vs []From) []B {
        var r = make([]B, len(vs))
        for i := range vs {
                r[i] = vs[i]
        }
        return r
}

func main() {
        var x [100]Ta
        var _ = ConvertSliceToA(x[:])
        
        var y [100]Tb
        var _ = ConvertSliceToB(y[:])
}

-- 
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/fa05695e-f891-41e3-a647-fff56b6b112cn%40googlegroups.com.

Reply via email to