aboutsummaryrefslogtreecommitdiff
path: root/lib/std/buffer.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-01-27 13:32:39 -0500
committerAndrew Kelley <andrew@ziglang.org>2020-01-27 13:32:39 -0500
commite2778c03e07c23d60861b90474859b9d8a62bce8 (patch)
treeacd9f43605fcbea6fe9d1edf4694081fc003f819 /lib/std/buffer.zig
parent1a08c0d40b8c6e72532762281365a5105116dc00 (diff)
parentd8965002593c111069862e7de06402ee77b2b614 (diff)
downloadzig-e2778c03e07c23d60861b90474859b9d8a62bce8.tar.gz
zig-e2778c03e07c23d60861b90474859b9d8a62bce8.zip
Merge branch 'master' into ir-clean-up-vars
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 {