Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for PrintWithPrinter (0.14 sec)

  1. test/typeparam/issue50690c.go

    type Printer[T ~string] struct {
    	PrintFn func(T)
    }
    
    func Print[T ~string](s T) {
    	fmt.Println(s)
    }
    
    func PrintWithPrinter[T ~string, S interface {
    	~struct {
    		ID       T
    		PrintFn_ func(T)
    	}
    	PrintFn() func(T)
    }](message T, obj S) {
    	obj.PrintFn()(message)
    }
    
    func main() {
    	PrintWithPrinter(
    		"Hello, world.",
    		StructWithPrinter{ID: "fake", PrintFn_: Print[string]},
    	)
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Mar 09 21:26:42 UTC 2022
    - 917 bytes
    - Viewed (0)
  2. test/typeparam/issue50690b.go

    package main
    
    import (
    	"fmt"
    )
    
    type Printer[T ~string] struct {
    	PrintFn func(T)
    }
    
    func Print[T ~string](s T) {
    	fmt.Println(s)
    }
    
    func PrintWithPrinter[T ~string, S interface {
    	~struct {
    		ID       T
    		PrintFn_ func(T)
    	}
    	PrintFn() func(T)
    }](message T, obj S) {
    	obj.PrintFn()(message)
    }
    
    type PrintShop[T ~string] struct {
    	ID       T
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Mar 09 21:26:42 UTC 2022
    - 916 bytes
    - Viewed (0)
Back to top