MCPcopy
hub / github.com/google/go-cmp / IsType

Function IsType

cmp/internal/function/func.go:41–73  ·  view source on GitHub ↗

IsType reports whether the reflect.Type is of the specified function type.

(t reflect.Type, ft funcType)

Source from the content-addressed store, hash-verified

39
40// IsType reports whether the reflect.Type is of the specified function type.
41func IsType(t reflect.Type, ft funcType) bool {
42 if t == nil || t.Kind() != reflect.Func || t.IsVariadic() {
43 return false
44 }
45 ni, no := t.NumIn(), t.NumOut()
46 switch ft {
47 case tbFunc: // func(T) bool
48 if ni == 1 && no == 1 && t.Out(0) == boolType {
49 return true
50 }
51 case ttbFunc: // func(T, T) bool
52 if ni == 2 && no == 1 && t.In(0) == t.In(1) && t.Out(0) == boolType {
53 return true
54 }
55 case ttiFunc: // func(T, T) int
56 if ni == 2 && no == 1 && t.In(0) == t.In(1) && t.Out(0) == intType {
57 return true
58 }
59 case trbFunc: // func(T, R) bool
60 if ni == 2 && no == 1 && t.Out(0) == boolType {
61 return true
62 }
63 case tibFunc: // func(T, I) bool
64 if ni == 2 && no == 1 && t.In(0).AssignableTo(t.In(1)) && t.Out(0) == boolType {
65 return true
66 }
67 case trFunc: // func(T) R
68 if ni == 1 && no == 1 {
69 return true
70 }
71 }
72 return false
73}
74
75var lastIdentRx = regexp.MustCompile(`[_\p{L}][_\p{L}\p{N}]*$`)
76

Callers 8

tryMethodMethod · 0.92
FilterValuesFunction · 0.92
TransformerFunction · 0.92
ComparerFunction · 0.92
SortSlicesFunction · 0.92
SortMapsFunction · 0.92
IgnoreSliceElementsFunction · 0.92
IgnoreMapEntriesFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…