From 00a07a4de190edfad5f16e22e238c4b5c37e2cba Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Fri, 26 Jul 2024 17:26:39 +0300 Subject: Added msginfo command --- src/Bot.zig | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/Bot.zig') diff --git a/src/Bot.zig b/src/Bot.zig index 45717e1..0346d2c 100644 --- a/src/Bot.zig +++ b/src/Bot.zig @@ -1,5 +1,6 @@ -const types = @import("types.zig"); const std = @import("std"); +const types = @import("types.zig"); +const utils = @import("utils.zig"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; @@ -176,14 +177,6 @@ fn call( } } -inline fn isNull(value: anytype) bool { - return switch (@typeInfo(@TypeOf(value))) { - .Null => true, - .Optional => value == null, - else => false, - }; -} - fn intoQueryString(allocator: Allocator, data: anytype) !?[]u8 { return switch (@typeInfo(@TypeOf(data))) { .Null => null, @@ -195,7 +188,7 @@ fn intoQueryString(allocator: Allocator, data: anytype) !?[]u8 { var counter: usize = 0; inline for (s.fields) |field| { - if (!isNull(@field(data, field.name))) { + if (!utils.isNull(@field(data, field.name))) { counter += 1; try sb.ensureUnusedCapacity(field.name.len + 2); -- cgit v1.2.3