diff options
Diffstat (limited to '')
-rw-r--r-- | src/string_mutable.zig | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/string_mutable.zig b/src/string_mutable.zig index e6738ae7f..cb8e1633e 100644 --- a/src/string_mutable.zig +++ b/src/string_mutable.zig @@ -235,6 +235,13 @@ pub const MutableString = struct { return self.list.items; } + /// Clear the existing value without freeing the memory or shrinking the capacity. + pub fn move(self: *MutableString) []u8 { + const out = self.list.items; + self.list = .{}; + return out; + } + 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( |