feat(jet): add ExprPtrs for pointer slice expressions
ExprPtrs dereferences []*T values, skips nil entries, and maps survivors through a converter. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+13
@@ -16,6 +16,19 @@ func ExprValues[T any](values []T, f func(T) Expression) []Expression {
|
||||
return expressions
|
||||
}
|
||||
|
||||
// ExprPtrs converts a list of pointers to Expression values, skipping nil
|
||||
// entries. Function f receives the dereferenced value.
|
||||
func ExprPtrs[T any](values []*T, f func(T) Expression) []Expression {
|
||||
expressions := make([]Expression, 0, len(values))
|
||||
for _, v := range values {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
expressions = append(expressions, f(*v))
|
||||
}
|
||||
return expressions
|
||||
}
|
||||
|
||||
// ExprStringers converts a list of fmt.Stringers to a list of Expression values.
|
||||
func ExprStringers(values []fmt.Stringer) []Expression {
|
||||
expressions := make([]Expression, len(values))
|
||||
|
||||
Reference in New Issue
Block a user