Get the latest tech news
Zig's (.{}){} Syntax
A look at some unfriendly Zig syntax
This is a combination of three separate language features: generics, anonymous struct literals and default field values. Thinking of Node(i32) as a type can take a bit of getting used to, but once you accept that it's no different than any other struct, the 2nd initialization hopefully makes sense. I've written more about generics before and, in the next post, we'll talk about a new Zig feature, declaration literals, which improve the readability of this type of code.
Or read this on Hacker News