diff options
| author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2024-11-02 15:54:34 +0000 |
|---|---|---|
| committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2024-11-02 15:54:34 +0000 |
| commit | d0d31ae73ad4d4445ccadcb0e891d3527230fcfc (patch) | |
| tree | 0617d82b3911c786ebbbee36f4acab776a0d85bb | |
| parent | 71b4f5ea8130432c162de1f230c95d19f43b24a3 (diff) | |
| parent | 530dcde3d413849dc2fea18eddcfb8cf85a76cb0 (diff) | |
Merge pull request 'reuse fields' (#173) from rofrol/ziglings--exercises:reuse-fields into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/173
| -rw-r--r-- | exercises/065_builtins2.zig | 7 | ||||
| -rw-r--r-- | patches/patches/065_builtins2.patch | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/exercises/065_builtins2.zig b/exercises/065_builtins2.zig index 0790db4..21a3911 100644 --- a/exercises/065_builtins2.zig +++ b/exercises/065_builtins2.zig @@ -110,15 +110,16 @@ pub fn main() void { // name will not be printed if the field is of type 'void' // (which is a zero-bit type that takes up no space at all!): if (fields[0].??? != void) { - print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[0].name}); + print(" {s}", .{fields.name}); + print(" {s}", .{fields[0].name}); } if (fields[1].??? != void) { - print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[1].name}); + print(" {s}", .{fields[1].name}); } if (fields[2].??? != void) { - print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[2].name}); + print(" {s}", .{fields[2].name}); } // Yuck, look at all that repeated code above! I don't know diff --git a/patches/patches/065_builtins2.patch b/patches/patches/065_builtins2.patch index d5da950..d6f0839 100644 --- a/patches/patches/065_builtins2.patch +++ b/patches/patches/065_builtins2.patch @@ -24,16 +24,16 @@ // (which is a zero-bit type that takes up no space at all!): - if (fields[0].??? != void) { + if (fields[0].type != void) { - print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[0].name}); + print(" {s}", .{fields[0].name}); } - if (fields[1].??? != void) { + if (fields[1].type != void) { - print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[1].name}); + print(" {s}", .{fields[1].name}); } - if (fields[2].??? != void) { + if (fields[2].type != void) { - print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[2].name}); + print(" {s}", .{fields[2].name}); } |
