aboutsummaryrefslogtreecommitdiff
path: root/lib/std/buffer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/buffer.zig')
-rw-r--r--lib/std/buffer.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/buffer.zig b/lib/std/buffer.zig
index 6313d693b7..42bf8e8142 100644
--- a/lib/std/buffer.zig
+++ b/lib/std/buffer.zig
@@ -57,11 +57,11 @@ pub const Buffer = struct {
/// The caller owns the returned memory. The Buffer becomes null and
/// is safe to `deinit`.
- pub fn toOwnedSlice(self: *Buffer) []u8 {
+ pub fn toOwnedSlice(self: *Buffer) [:0]u8 {
const allocator = self.list.allocator;
- const result = allocator.shrink(self.list.items, self.len());
+ const result = self.list.toOwnedSlice();
self.* = initNull(allocator);
- return result;
+ return result[0 .. result.len - 1 :0];
}
pub fn allocPrint(allocator: *Allocator, comptime format: []const u8, args: var) !Buffer {