1const std = @import("std");
2const string = []const u8;
3const extras = @import("./lib.zig");
4
5pub fn join(input: anytype) Join(@TypeOf(input)) {
6 const T = @TypeOf(input);
7 var x: Join(T) = undefined;
8 inline for (std.meta.fields(T)) |item| {
9 inline for (std.meta.fields(item.type)) |f| {
10 @field(x, f.name) = @field(@field(input, item.name), f.name);
11 }
12 }
13 return x;
14}
15
16pub fn Join(comptime T: type) type {
17 var names: []const []const u8 = &.{};
18 var types: []const type = &.{};
19 inline for (std.meta.fields(T)) |item| {
20 inline for (std.meta.fields(item.type)) |f| {
21 names = names ++ &[_][]const u8{f.name};
22 types = types ++ &[_]type{f.type};
23 }
24 }
25 return @Struct(.auto, null, names, types[0..], &@splat(.{}));
26}