#[solved] How to create a struct with fields that mirror an enum

1 messages · Page 1 of 1 (latest)

chilly hull
#
const Goal = struct { one:bool, two:bool };
const Enum = enum { one, two };

fn generate (compime T: type) type { return struct { ???? }; }
const MyType = generate(Enum);  // <--- Should be equivalent to the struct Goal
```What tools would I need to generate this type of thing?
chilly hull
digital beacon
#

do the same thing that function does but change layout to packed in the @type at the end

chilly hull
digital beacon
#

here are the union variants you can pass into @Type and here is the info you need to provide for a struct

#

packed isn't a different thing, it's an attribute of structs

#

so it'd be @Type(.{ .@"struct" = .{ .layout = .@"packed", ... } })

chilly hull
#

oh, its @"packed", ok

#

didn't know where to find those, tyty