MCPcopy
hub / github.com/spf13/cast / toUnsignedNumber

Function toUnsignedNumber

number.go:195–276  ·  view source on GitHub ↗
(i any)

Source from the content-addressed store, hash-verified

193}
194
195func toUnsignedNumber[T Number](i any) (T, bool, bool) {
196 i, _ = indirect(i)
197
198 switch s := i.(type) {
199 case T:
200 return s, true, true
201 case int:
202 if s < 0 {
203 return 0, false, false
204 }
205
206 return T(s), true, true
207 case int8:
208 if s < 0 {
209 return 0, false, false
210 }
211
212 return T(s), true, true
213 case int16:
214 if s < 0 {
215 return 0, false, false
216 }
217
218 return T(s), true, true
219 case int32:
220 if s < 0 {
221 return 0, false, false
222 }
223
224 return T(s), true, true
225 case int64:
226 if s < 0 {
227 return 0, false, false
228 }
229
230 return T(s), true, true
231 case uint:
232 return T(s), true, true
233 case uint8:
234 return T(s), true, true
235 case uint16:
236 return T(s), true, true
237 case uint32:
238 return T(s), true, true
239 case uint64:
240 return T(s), true, true
241 case float32:
242 if s < 0 {
243 return 0, false, false
244 }
245
246 return T(s), true, true
247 case float64:
248 if s < 0 {
249 return 0, false, false
250 }
251
252 return T(s), true, true

Callers

nothing calls this directly

Calls 1

indirectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…