1 // Copyright 2017, 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.md file.
5 // Package function identifies function types.
15 ttbFunc // func(T, T) bool
16 tibFunc // func(T, I) bool
19 Equal = ttbFunc // func(T, T) bool
20 EqualAssignable = tibFunc // func(T, I) bool; encapsulates func(T, T) bool
21 Transformer = trFunc // func(T) R
22 ValueFilter = ttbFunc // func(T, T) bool
23 Less = ttbFunc // func(T, T) bool
26 var boolType = reflect.TypeOf(true)
28 // IsType reports whether the reflect.Type is of the specified function type.
29 func IsType(t reflect.Type, ft funcType) bool {
30 if t == nil || t.Kind() != reflect.Func || t.IsVariadic() {
33 ni, no := t.NumIn(), t.NumOut()
35 case ttbFunc: // func(T, T) bool
36 if ni == 2 && no == 1 && t.In(0) == t.In(1) && t.Out(0) == boolType {
39 case tibFunc: // func(T, I) bool
40 if ni == 2 && no == 1 && t.In(0).AssignableTo(t.In(1)) && t.Out(0) == boolType {
43 case trFunc: // func(T) R
44 if ni == 1 && no == 1 {