aboutsummaryrefslogtreecommitdiff
path: root/src/string_mutable.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/string_mutable.zig')
-rw-r--r--src/string_mutable.zig13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/string_mutable.zig b/src/string_mutable.zig
index d846bf312..f6cf12799 100644
--- a/src/string_mutable.zig
+++ b/src/string_mutable.zig
@@ -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);
// }