MCPcopy Index your code
hub / github.com/expr-lang/expr / toInt

Function toInt

builtin/utils.go:44–69  ·  view source on GitHub ↗
(val any)

Source from the content-addressed store, hash-verified

42}
43
44func toInt(val any) (int, error) {
45 switch v := val.(type) {
46 case int:
47 return v, nil
48 case int8:
49 return int(v), nil
50 case int16:
51 return int(v), nil
52 case int32:
53 return int(v), nil
54 case int64:
55 return int(v), nil
56 case uint:
57 return int(v), nil
58 case uint8:
59 return int(v), nil
60 case uint16:
61 return int(v), nil
62 case uint32:
63 return int(v), nil
64 case uint64:
65 return int(v), nil
66 default:
67 return 0, fmt.Errorf("cannot use %T as argument (type int)", val)
68 }
69}
70
71func bitFunc(name string, fn func(x, y int) (any, error)) *Function {
72 return &Function{

Callers 2

bitFuncFunction · 0.85
builtin.goFile · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…