This commit is contained in:
Jarred Sumner
2021-04-22 14:24:28 -07:00
parent bee68ecc00
commit da509f3d5a
5 changed files with 92 additions and 9 deletions

View File

@@ -70,8 +70,8 @@ pub const MutableString = struct {
try self.list.append(self.allocator, char);
}
pub fn appendCharAssumeCapacity(self: *MutableString, char: u8) !void {
try self.list.appendAssumeCapacity(self.allocator, char);
pub fn appendCharAssumeCapacity(self: *MutableString, char: u8) void {
self.list.appendAssumeCapacity(char);
}
pub fn append(self: *MutableString, char: []const u8) !void {
@@ -82,6 +82,15 @@ pub const MutableString = struct {
try self.list.appendSliceAssumeCapacity(self.allocator, char);
}
pub fn toOwnedSlice(self: *MutableString) string {
return self.list.toOwnedSlice(self.allocator);
}
pub fn toOwnedSliceLength(self: *MutableString, length: usize) string {
self.list.shrinkAndFree(self.allocator, length);
return self.list.toOwnedSlice(self.allocator);
}
// pub fn deleteAt(self: *MutableString, i: usize) {
// self.list.swapRemove(i);
// }