Elements iterate over the elements of a Static value. If the Static is not an array, it will loop over itself as the only element
()
| 929 | // Elements iterate over the elements of a Static value. If the Static is not an array, |
| 930 | // it will loop over itself as the only element |
| 931 | func (s Static) Elements() iter.Seq2[int, Static] { |
| 932 | return func(fn func(int, Static) bool) { |
| 933 | switch s.Type { |
| 934 | case TypeIntArray: |
| 935 | ints, _ := s.IntArray() |
| 936 | for i, n := range ints { |
| 937 | if !fn(i, NewStaticInt(n)) { |
| 938 | return |
| 939 | } |
| 940 | } |
| 941 | case TypeFloatArray: |
| 942 | floats, _ := s.FloatArray() |
| 943 | for i, f := range floats { |
| 944 | if !fn(i, NewStaticFloat(f)) { |
| 945 | return |
| 946 | } |
| 947 | } |
| 948 | case TypeStringArray: |
| 949 | strs, _ := s.StringArray() |
| 950 | for i, str := range strs { |
| 951 | if !fn(i, NewStaticString(str)) { |
| 952 | return |
| 953 | } |
| 954 | } |
| 955 | case TypeBooleanArray: |
| 956 | bools, _ := s.BooleanArray() |
| 957 | for i, b := range bools { |
| 958 | if !fn(i, NewStaticBool(b)) { |
| 959 | return |
| 960 | } |
| 961 | } |
| 962 | default: |
| 963 | fn(0, s) |
| 964 | } |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | func (s Static) Int() (int, bool) { |
| 969 | if s.Type != TypeInt { |
no test coverage detected