commit 95439c982033bf56a54f4dd85e6de951b52aeb0d (tree)
parent 354c17869a4fb1053d472d6562f4987fbaca143e
Author: Andrew Kelley <andrew@ziglang.org>
Date: Wed, 3 Sep 2025 15:25:41 -0700
std.Progress: avoid problematic catch syntax
Diffstat:
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig
@@ -1248,7 +1248,9 @@ fn computeRedraw(serialized_buffer: *Serialized.Buffer) struct { []u8, usize } {
i += progress_pulsing.len;
} else {
const percent = completed_items * 100 / estimated_total;
- i += (std.fmt.bufPrint(buf[i..], @"progress_normal {d}", .{percent}) catch &.{}).len;
+ if (std.fmt.bufPrint(buf[i..], @"progress_normal {d}", .{percent})) |b| {
+ i += b.len;
+ } else |_| {}
}
},
.success => {
@@ -1265,7 +1267,9 @@ fn computeRedraw(serialized_buffer: *Serialized.Buffer) struct { []u8, usize } {
i += progress_pulsing_error.len;
} else {
const percent = completed_items * 100 / estimated_total;
- i += (std.fmt.bufPrint(buf[i..], @"progress_error {d}", .{percent}) catch &.{}).len;
+ if (std.fmt.bufPrint(buf[i..], @"progress_error {d}", .{percent})) |b| {
+ i += b.len;
+ } else |_| {}
}
},
}
@@ -1364,12 +1368,18 @@ fn computeNode(
if (!is_empty_root) {
if (name.len != 0 or estimated_total > 0) {
if (estimated_total > 0) {
- i += (std.fmt.bufPrint(buf[i..], "[{d}/{d}] ", .{ completed_items, estimated_total }) catch &.{}).len;
+ if (std.fmt.bufPrint(buf[i..], "[{d}/{d}] ", .{ completed_items, estimated_total })) |b| {
+ i += b.len;
+ } else |_| {}
} else if (completed_items != 0) {
- i += (std.fmt.bufPrint(buf[i..], "[{d}] ", .{completed_items}) catch &.{}).len;
+ if (std.fmt.bufPrint(buf[i..], "[{d}] ", .{completed_items})) |b| {
+ i += b.len;
+ } else |_| {}
}
if (name.len != 0) {
- i += (std.fmt.bufPrint(buf[i..], "{s}", .{name}) catch &.{}).len;
+ if (std.fmt.bufPrint(buf[i..], "{s}", .{name})) |b| {
+ i += b.len;
+ } else |_| {}
}
}