starting to work

Former-commit-id: ae113559c6
This commit is contained in:
Jarred Sumner
2021-06-27 23:36:35 -07:00
parent b918e7e372
commit adbeb24979
21 changed files with 1011 additions and 508 deletions

View File

@@ -154,10 +154,21 @@ pub const MutableString = struct {
return self.list.toOwnedSlice(self.allocator);
}
pub fn toOwnedSliceLeaky(self: *MutableString) string {
pub fn toOwnedSliceLeaky(self: *MutableString) []u8 {
return self.list.items;
}
pub fn toOwnedSentinelLeaky(self: *MutableString) [:0]u8 {
if (self.list.items.len > 0 and self.list.items[self.list.items.len - 1] != 0) {
self.list.append(
self.allocator,
0,
) catch unreachable;
}
return self.list.items[0 .. self.list.items.len - 1 :0];
}
pub fn toOwnedSliceLength(self: *MutableString, length: usize) string {
self.list.shrinkAndFree(self.allocator, length);
return self.list.toOwnedSlice(self.allocator);