From e7c110f1e082f3e68e25f454d5fd8fb41b8c794b Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 31 May 2026 22:22:50 -0700 Subject: [PATCH] use extras.parseDigits --- licenses.txt | 1 + sRGB.zig | 13 +++++++------ zigmod.yml | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/licenses.txt b/licenses.txt index 728089f444b1699f3c94f6841d719abda91c029f..830ca100462ce8e12dbcbaceb924f0edbd5eed3d 100644 --- a/licenses.txt +++ b/licenses.txt @@ -2,3 +2,4 @@ MIT: = https://spdx.org/licenses/MIT - This - git https://github.com/nektro/zig-expect +- git https://github.com/nektro/zig-extras diff --git a/sRGB.zig b/sRGB.zig index a4d65c5a41376078932853bbca4aa495525c1102..7e936daaf26b65d72433e937320ec316fd133617 100644 --- a/sRGB.zig +++ b/sRGB.zig @@ -1,6 +1,7 @@ //! object representing a single color in the sRGB colorspace with channel values from 0-255 const std = @import("std"); +const extras = @import("extras"); const Self = @This(); const color = @import("./mod.zig"); const _x = @import("./_x.zig"); @@ -27,9 +28,9 @@ pub fn initRGB(r: u8, g: u8, b: u8) Self { pub fn parseHexConst(comptime input: *const [7:0]u8) Self { comptime std.debug.assert(input[0] == '#'); return comptime initRGB( - std.fmt.parseInt(u8, input[1..3], 16) catch unreachable, - std.fmt.parseInt(u8, input[3..5], 16) catch unreachable, - std.fmt.parseInt(u8, input[5..7], 16) catch unreachable, + extras.parseDigits(u8, input[1..3], 16) catch unreachable, + extras.parseDigits(u8, input[3..5], 16) catch unreachable, + extras.parseDigits(u8, input[5..7], 16) catch unreachable, ); } @@ -37,9 +38,9 @@ pub fn parseHex(input: []const u8) Self { std.debug.assert(input.len == 7); std.debug.assert(input[0] == '#'); return initRGB( - std.fmt.parseInt(u8, input[1..3], 16) catch unreachable, - std.fmt.parseInt(u8, input[3..5], 16) catch unreachable, - std.fmt.parseInt(u8, input[5..7], 16) catch unreachable, + extras.parseDigits(u8, input[1..3], 16) catch unreachable, + extras.parseDigits(u8, input[3..5], 16) catch unreachable, + extras.parseDigits(u8, input[5..7], 16) catch unreachable, ); } diff --git a/zigmod.yml b/zigmod.yml index c1cf05c32ed3fecc673e5ec32823ddb5963f5231..7295a9702feac86edc277a89bfebd2b80d0daec9 100644 --- a/zigmod.yml +++ b/zigmod.yml @@ -4,5 +4,6 @@ main: mod.zig license: MIT description: Color init and transformation library for Zig dependencies: + - src: git https://github.com/nektro/zig-extras root_dependencies: - src: git https://github.com/nektro/zig-expect -- 2.54.0