From 9dd57ec3448c9bf798bf7dbb31bcdccfe390ead3 Mon Sep 17 00:00:00 2001 From: Nir Lahad Date: Thu, 3 Jul 2025 19:57:40 +0300 Subject: [PATCH] Remove error from `Class.addMethod` return type This function does not return an error; it also makes it consistent with `addIvar` function. --- src/class.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/class.zig b/src/class.zig index cf3373e..4691698 100644 --- a/src/class.zig +++ b/src/class.zig @@ -66,10 +66,10 @@ pub const Class = struct { _ = c.class_replaceMethod(self.value, objc.sel(name).value, @ptrCast(&imp), null); } - /// allows adding new methods; returns true on success. + // allows adding new methods; returns true on success. // imp should be a function with C calling convention // whose first two arguments are a `c.id` and a `c.SEL`. - pub fn addMethod(self: Class, name: [:0]const u8, imp: anytype) !bool { + pub fn addMethod(self: Class, name: [:0]const u8, imp: anytype) bool { const Fn = @TypeOf(imp); const fn_info = @typeInfo(Fn).@"fn"; assert(std.meta.eql(fn_info.calling_convention, std.builtin.CallingConvention.c)); @@ -207,7 +207,7 @@ test "addMethod" { const My_Class = setup: { const My_Class = allocateClassPair(objc.getClass("NSObject").?, "my_class").?; defer registerClassPair(My_Class); - std.debug.assert(try My_Class.addMethod("my_addition", struct { + std.debug.assert(My_Class.addMethod("my_addition", struct { fn imp(target: objc.c.id, sel: objc.c.SEL, a: i32, b: i32) callconv(.C) i32 { _ = sel; _ = target;