Created
September 23, 2018 18:07
-
-
Save winksaville/ac77c92619b23ad1763f267bfc078a17 to your computer and use it in GitHub Desktop.
Extending zig structs at compile time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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