std.fmt.digits now accept u8 instead of usize

See https://github.com/ziglang/zig/pull/22864 .

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
This commit is contained in:
Eric Joldasov 2025-02-13 22:51:35 +05:00
parent 1e55747cf7
commit 173f14f8e2
No known key found for this signature in database
GPG key ID: 5C9C69060686B588

View file

@ -126,14 +126,14 @@ pub const Writer = struct {
var index: usize = buf.len; var index: usize = buf.len;
while (a >= 100) : (a = @divTrunc(a, 100)) { while (a >= 100) : (a = @divTrunc(a, 100)) {
index -= 2; index -= 2;
buf[index..][0..2].* = std.fmt.digits2(@as(usize, @intCast(a % 100))); buf[index..][0..2].* = std.fmt.digits2(@as(u8, @intCast(a % 100)));
} }
if (a < 10) { if (a < 10) {
index -= 1; index -= 1;
buf[index] = '0' + @as(u8, @intCast(a)); buf[index] = '0' + @as(u8, @intCast(a));
} else { } else {
index -= 2; index -= 2;
buf[index..][0..2].* = std.fmt.digits2(@as(usize, @intCast(a))); buf[index..][0..2].* = std.fmt.digits2(@as(u8, @intCast(a)));
} }
ctx.write(buf[index..]); ctx.write(buf[index..]);
} }