-
-
Save nodefish/34f79a36287117c602b945dc5ec1f83b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const builtin = @import("builtin"); | |
const Row = struct { | |
age: u32, | |
name: []u8, | |
}; | |
const RuntimeStructField = struct { | |
name: []const u8, | |
//offset: ?comptime_int, | |
//field_type: type, | |
}; | |
test "whatever" { | |
comptime const fields = init: { | |
comptime var arr: [@typeInfo(Row).Struct.fields.len]RuntimeStructField = undefined; | |
inline for (@typeInfo(Row).Struct.fields) |field, i| { | |
arr[i] = RuntimeStructField{ | |
.name = field.name, | |
//.offset = field.offset, | |
//.field_type = field.field_type, | |
}; | |
} | |
break :init arr; | |
}; | |
std.debug.warn("\n{}\n", fields[0]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment