From af2d710000cbe42068f419356f3d2f1511a3326b Mon Sep 17 00:00:00 2001 From: David Mo Date: Tue, 25 Feb 2025 10:15:58 -0500 Subject: [PATCH] rename `setToDefault` to `init` --- src/cli/args.zig | 8 ++++---- src/config/Config.zig | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cli/args.zig b/src/cli/args.zig index 420a014dc..bf927a414 100644 --- a/src/cli/args.zig +++ b/src/cli/args.zig @@ -262,8 +262,8 @@ pub fn parseIntoField( if (value) |v| default: { if (v.len != 0) break :default; // Set default value if possible. - if (canHaveDecls and @hasDecl(Field, "setToDefault")) { - try @field(dst, field.name).setToDefault(alloc); + if (canHaveDecls and @hasDecl(Field, "init")) { + try @field(dst, field.name).init(alloc); return; } const raw = field.default_value orelse break :default; @@ -767,7 +767,7 @@ test "parseIntoField: ignore underscore-prefixed fields" { try testing.expectEqualStrings("12", data._a); } -test "parseIntoField: struct with default func" { +test "parseIntoField: struct with init func" { const testing = std.testing; var arena = ArenaAllocator.init(testing.allocator); defer arena.deinit(); @@ -779,7 +779,7 @@ test "parseIntoField: struct with default func" { v: []const u8, - pub fn setToDefault(self: *Self, _alloc: Allocator) !void { + pub fn init(self: *Self, _alloc: Allocator) !void { _ = _alloc; self.v = "HELLO!"; } diff --git a/src/config/Config.zig b/src/config/Config.zig index 6d2a0f424..d2c033cdc 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -2373,7 +2373,7 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config { const alloc = result._arena.?.allocator(); // Add our default keybindings - try result.keybind.setToDefault(alloc); + try result.keybind.init(alloc); // Add our default link for URL detection try result.link.links.append(alloc, .{ @@ -4492,7 +4492,7 @@ pub const RepeatableFontVariation = struct { pub const Keybinds = struct { set: inputpkg.Binding.Set = .{}, - pub fn setToDefault(self: *Keybinds, alloc: Allocator) !void { + pub fn init(self: *Keybinds, alloc: Allocator) !void { // We don't clear the memory because it's in the arena and unlikely // to be free-able anyways (since arenas can only clear the last // allocated value). This isn't a memory leak because the arena @@ -5131,7 +5131,7 @@ pub const Keybinds = struct { // Check for special values if (value.len == 0) { log.info("config has 'keybind =', using default keybinds", .{}); - try self.setToDefault(alloc); + try self.init(alloc); return; }