refactor: use *std.Io.Writer instead of anytype

This commit is contained in:
CJ van den Berg 2025-12-12 14:11:28 +01:00
parent 99b721febf
commit 660449c1c0
2 changed files with 3 additions and 3 deletions

View file

@ -90,11 +90,11 @@ pub fn toggle_prefix_in_text(prefix: []const u8, text: []const u8, allocator: st
return result.toOwnedSlice(allocator); return result.toOwnedSlice(allocator);
} }
pub fn write_string(writer: anytype, string: []const u8, pad: ?usize) !void { pub fn write_string(writer: *std.Io.Writer, string: []const u8, pad: ?usize) !void {
try writer.writeAll(string); try writer.writeAll(string);
if (pad) |pad_| try write_padding(writer, string.len, pad_); if (pad) |pad_| try write_padding(writer, string.len, pad_);
} }
pub fn write_padding(writer: anytype, len: usize, pad_len: usize) !void { pub fn write_padding(writer: *std.Io.Writer, len: usize, pad_len: usize) !void {
for (0..pad_len - len) |_| try writer.writeAll(" "); for (0..pad_len - len) |_| try writer.writeAll(" ");
} }

View file

@ -74,7 +74,7 @@ fn update_max_col_sizes(palette: *Type, comp_sizes: []const usize) u8 {
return total_length; return total_length;
} }
fn write_columns(palette: *Type, writer: anytype, column_info: [][]const u8) void { fn write_columns(palette: *Type, writer: *std.Io.Writer, column_info: [][]const u8) void {
if (palette.value.column_size.len == 0) if (palette.value.column_size.len == 0)
return; return;
write_string(writer, column_info[0][0..@min(palette.value.column_size[0], column_info[0].len)], columns[0].max_width) catch {}; write_string(writer, column_info[0][0..@min(palette.value.column_size[0], column_info[0].len)], columns[0].max_width) catch {};