Function
IsFastFunc
(fn reflect.Type, method bool)
Source from the content-addressed store, hash-verified
| 102 | } |
| 103 | |
| 104 | func IsFastFunc(fn reflect.Type, method bool) bool { |
| 105 | if fn == nil { |
| 106 | return false |
| 107 | } |
| 108 | if fn.Kind() != reflect.Func { |
| 109 | return false |
| 110 | } |
| 111 | numIn := 1 |
| 112 | if method { |
| 113 | numIn = 2 |
| 114 | } |
| 115 | if fn.IsVariadic() && |
| 116 | fn.NumIn() == numIn && |
| 117 | fn.NumOut() == 1 && |
| 118 | fn.Out(0).Kind() == reflect.Interface { |
| 119 | rest := fn.In(fn.NumIn() - 1) // function has only one param for functions and two for methods |
| 120 | if rest != nil && rest.Kind() == reflect.Slice && rest.Elem().Kind() == reflect.Interface { |
| 121 | return true |
| 122 | } |
| 123 | } |
| 124 | return false |
| 125 | } |
Tested by
no test coverage detected
Used in the wild real call sites across dependent graphs
searching dependent graphs…