Skip to content

Instantly share code, notes, and snippets.

@nodefish

nodefish/wb3.zig Secret

Created April 24, 2019 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nodefish/34f79a36287117c602b945dc5ec1f83b to your computer and use it in GitHub Desktop.
Save nodefish/34f79a36287117c602b945dc5ec1f83b to your computer and use it in GitHub Desktop.
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