Source file test/typeparam/issue51909.go

     1  // compile
     2  
     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.
     6  
     7  package main
     8  
     9  type None struct{}
    10  
    11  type Response interface {
    12  	send(ctx *struct{})
    13  }
    14  
    15  type HandlerFunc[Input any] func(Input) Response
    16  
    17  func Operation[Input any](method, path string, h HandlerFunc[Input]) {
    18  	var input Input
    19  	h(input)
    20  }
    21  
    22  func Get[Body any](path string, h HandlerFunc[struct{ Body Body }]) {
    23  	Operation("GET", path, h)
    24  }
    25  
    26  func main() {
    27  	Get("/", func(req struct{ Body None }) Response {
    28  		return nil
    29  	})
    30  }
    31  

View as plain text