diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-01-29 23:33:12 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-01-29 23:33:12 -0500 |
| commit | a95dce15ae4bd95cfd2266da51ba860cc6524a1b (patch) | |
| tree | e761ecb74f37ff699d2e1f09d122811b101826e4 /lib/std/buffer.zig | |
| parent | 800ead2810fa573a7e94979e707a14d4e066ef77 (diff) | |
| parent | 7ebc624a15c5a01d6bee8eaf9c7487b30ed1904c (diff) | |
| download | zig-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.zig | 6 |
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 { |
