ToExpressionSet is a convenience function that accepts a slice of expressions and builds the corresponding ExpressionSet.
(slice any)
| 101 | // ToExpressionSet is a convenience function that accepts a slice of expressions |
| 102 | // and builds the corresponding ExpressionSet. |
| 103 | func ToExpressionSet(slice any) ExpressionSet { |
| 104 | if slice == nil { |
| 105 | return nil |
| 106 | } |
| 107 | s := reflect.ValueOf(slice) |
| 108 | if s.Kind() != reflect.Slice { |
| 109 | panic("ToExpressionSet() given a non-slice type") // bug |
| 110 | } |
| 111 | ret := make(ExpressionSet, s.Len()) |
| 112 | for i := 0; i < s.Len(); i++ { |
| 113 | ret[i] = s.Index(i).Interface().(Expression) |
| 114 | } |
| 115 | |
| 116 | return ret |
| 117 | } |