refactor: make available write_padding function to other modules
This commit is contained in:
parent
ced915fedc
commit
c5e6d64235
3 changed files with 14 additions and 9 deletions
|
|
@ -89,3 +89,12 @@ pub fn toggle_prefix_in_text(prefix: []const u8, text: []const u8, allocator: st
|
|||
}
|
||||
return result.toOwnedSlice(allocator);
|
||||
}
|
||||
|
||||
pub fn write_string(writer: anytype, string: []const u8, pad: ?usize) !void {
|
||||
try writer.writeAll(string);
|
||||
if (pad) |pad_| try write_padding(writer, string.len, pad_);
|
||||
}
|
||||
|
||||
pub fn write_padding(writer: anytype, len: usize, pad_len: usize) !void {
|
||||
for (0..pad_len - len) |_| try writer.writeAll(" ");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue