aboutsummaryrefslogtreecommitdiff
path: root/lib/std/buffer.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-01-29 23:33:12 -0500
committerAndrew Kelley <andrew@ziglang.org>2020-01-29 23:33:12 -0500
commita95dce15ae4bd95cfd2266da51ba860cc6524a1b (patch)
treee761ecb74f37ff699d2e1f09d122811b101826e4 /lib/std/buffer.zig
parent800ead2810fa573a7e94979e707a14d4e066ef77 (diff)
parent7ebc624a15c5a01d6bee8eaf9c7487b30ed1904c (diff)
downloadzig-a95dce15ae4bd95cfd2266da51ba860cc6524a1b.tar.gz
zig-a95dce15ae4bd95cfd2266da51ba860cc6524a1b.zip
Merge remote-tracking branch 'origin/master' into llvm10
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 {