From 6494bbdf6085a12464f3dc1f455fce1d5dcf0e02 Mon Sep 17 00:00:00 2001 From: mitteneer Date: Tue, 20 May 2025 09:33:15 -0400 Subject: [PATCH] Remove Rules type --- src/app/jobs/process_rule.zig | 11 +++++------ src/types.zig | 4 ---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/app/jobs/process_rule.zig b/src/app/jobs/process_rule.zig index 7b60d54..6beb880 100644 --- a/src/app/jobs/process_rule.zig +++ b/src/app/jobs/process_rule.zig @@ -16,7 +16,7 @@ pub fn run(allocator: std.mem.Allocator, params: *jetzig.data.Value, env: jetzig return; }, }; - const out_rules = Data.Rules{ .rules = &[_]Data.Rule{rule} }; + const out_rules = &[_]Data.Rule{rule}; const out = try std.json.stringifyAlloc(allocator, out_rules, .{}); try file.writeAll(out); file.close(); @@ -35,18 +35,17 @@ pub fn run(allocator: std.mem.Allocator, params: *jetzig.data.Value, env: jetzig const file_write: std.fs.File = try std.fs.cwd().openFile("rules.json", .{ .mode = .write_only }); if (file_content.len == 0) { - const out_rules = Data.Rules{ .rules = &[_]Data.Rule{rule} }; + const out_rules = &[_]Data.Rule{rule}; const out = try std.json.stringifyAlloc(allocator, out_rules, .{}); try file_write.writeAll(out); file_write.close(); return; } - const content: Data.Rules = try std.json.parseFromSliceLeaky(Data.Rules, allocator, file_content, .{}); - try rules.appendSlice(content.rules); + const content: []Data.Rule = try std.json.parseFromSliceLeaky([]Data.Rule, allocator, file_content, .{}); + try rules.appendSlice(content); try rules.append(rule); - const out_rules = Data.Rules{ .rules = rules.items }; - const out = try std.json.stringifyAlloc(allocator, out_rules, .{}); + const out = try std.json.stringifyAlloc(allocator, rules.items, .{}); try file_write.writeAll(out); file_write.close(); diff --git a/src/types.zig b/src/types.zig index 202bce6..073b2d3 100644 --- a/src/types.zig +++ b/src/types.zig @@ -95,10 +95,6 @@ pub const Rule = struct { }, }; -pub const Rules = struct { - rules: []const Rule, -}; - // Can't import types in .zmpl files, so defining this here // doesn't really do much (except maybe in the .zig file for views?) //pub const HeaderTypes = []enum {