diff options
author | 2021-04-22 14:24:28 -0700 | |
---|---|---|
committer | 2021-04-22 14:24:28 -0700 | |
commit | da509f3d5a732145afebbc7400a832785f1b439f (patch) | |
tree | 11384b2bc80b405bffa1515e3ac2dfe993a229d2 /src/string_mutable.zig | |
parent | bee68ecc004864d1a1bbdfb0d49acf42ffe1f0d3 (diff) | |
download | bun-da509f3d5a732145afebbc7400a832785f1b439f.tar.gz bun-da509f3d5a732145afebbc7400a832785f1b439f.tar.zst bun-da509f3d5a732145afebbc7400a832785f1b439f.zip |
a
Diffstat (limited to 'src/string_mutable.zig')
-rw-r--r-- | src/string_mutable.zig | 13 |
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); // } |