≈ the.bay.news

Should Zig have a dedicated syntax for union initialization?

Ziggit
Should Zig have a dedicated syntax for union initialization?
Lately I’ve been developing a vulkan abstraction layer, and I use unions in a few places. In the process I have noticed that union initialization always feel a bit awkward and overly verbose. For struct initialization it’s obvious that we need an extra level of braces, a struct can have multiple fields, so it should have braces around it: const x: Struct = .{.y = .{...}, .z = .{...}}; But for unions, we know that there is only one variant, yet it still needs another level of braces const x: ...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.