Skip to content

Instantly share code, notes, and snippets.

@winksaville
Created September 23, 2018 18:07
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 winksaville/ac77c92619b23ad1763f267bfc078a17 to your computer and use it in GitHub Desktop.
Save winksaville/ac77c92619b23ad1763f267bfc078a17 to your computer and use it in GitHub Desktop.
Extending zig structs at compile time
const S1 = struct {
n: u32,
}
fn S2() type {
return S1 {
m: u64,
};
}
test "t" {
const x = S2() {
.n = 1,
.m = 2,
};
assert(x.n == 1);
assert(x.m == 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment