comptime expandable match statements

This commit is contained in:
2026-07-17 14:29:50 +02:00
parent 1f25e6cd1d
commit 97f1c06057
22 changed files with 120821 additions and 119318 deletions
+3 -3
View File
@@ -11,7 +11,7 @@ format func() []u8 {
sum func($T type, value T) i32 {
total i32 = 0
match typeinfo!(T) {
.record |record|: inline for record.fields |field| {
.record |record|: expand for record.fields |field| {
total += i32(field!(value, field.name))
}
else: compile_error!("sum requires a record")
@@ -22,7 +22,7 @@ sum func($T type, value T) i32 {
static_control func($T type, value T) i32 {
total i32 = 0
match typeinfo!(T) {
.record |record|: inline for record.fields |field| {
.record |record|: expand for record.fields |field| {
{
if field.index == 1 {
continue
@@ -50,7 +50,7 @@ row_value func(row Row) i32 {
static_aggregates func() i32 {
total i32 = 0
inline for {Row {value = 2}, Row {value = 40}} |row| {
expand for {Row {value = 2}, Row {value = 40}} |row| {
total += row_value(row)
}
return total