...

Source file src/internal/types/testdata/check/compliterals.go

Documentation: internal/types/testdata/check

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Composite literals with parameterized types
     6  
     7  package comp_literals
     8  
     9  type myStruct struct {
    10  	f int
    11  }
    12  
    13  type slice[E any] []E
    14  
    15  func struct_literals[S struct{f int}|myStruct]() {
    16  	_ = S{}
    17  	_ = S{0}
    18  	_ = S{f: 0}
    19  
    20          _ = slice[int]{1, 2, 3}
    21          _ = slice[S]{{}, {0}, {f:0}}
    22  }
    23  

View as plain text