3 // Copyright 2022 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.
13 type Printer[T ~string] struct {
17 func Print[T ~string](s T) {
21 func PrintWithPrinter[T ~string, S interface {
27 }](message T, obj S) {
28 obj.PrintFn()(message)
31 type PrintShop[T ~string] struct {
36 // Field accesses through type parameters are disabled
37 // until we have a more thorough understanding of the
38 // implications on the spec. See issue #51576.
39 // Use accessor method instead.
41 func (s PrintShop[T]) PrintFn() func(T) { return s.PrintFn_ }
48 PrintFn_: Print[string],