Source file test/typeparam/issue48453.go

     1  // run
     2  
     3  // Copyright 2021 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package main
     8  
     9  //go:noinline
    10  func CopyMap[M interface{ ~map[K]V }, K comparable, V any](m M) M {
    11  	out := make(M, len(m))
    12  	for k, v := range m {
    13  		out[k] = v
    14  	}
    15  	return out
    16  }
    17  
    18  func main() {
    19  	var m map[*string]int
    20  	CopyMap(m)
    21  }
    22  

View as plain text