MCPcopy Index your code
hub / github.com/cortexlabs/cortex / InterfaceToInt16

Function InterfaceToInt16

pkg/lib/cast/interface.go:90–115  ·  view source on GitHub ↗
(in interface{})

Source from the content-addressed store, hash-verified

88}
89
90func InterfaceToInt16(in interface{}) (int16, bool) {
91 var ok bool
92 if in, ok = JSONNumberToInt(in); !ok {
93 return 0, false
94 }
95
96 switch casted := in.(type) {
97 case int8:
98 return int16(casted), true
99 case int16:
100 return casted, true
101 case int32:
102 if val := int16(casted); int32(val) == casted {
103 return val, true
104 }
105 case int:
106 if val := int16(casted); int(val) == casted {
107 return val, true
108 }
109 case int64:
110 if val := int16(casted); int64(val) == casted {
111 return val, true
112 }
113 }
114 return 0, false
115}
116
117func InterfaceToInt16Downcast(in interface{}) (int16, bool) {
118 var ok bool

Callers

nothing calls this directly

Calls 1

JSONNumberToIntFunction · 0.85

Tested by

no test coverage detected