aboutsummaryrefslogtreecommitdiff
path: root/lib/std/buffer.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-01-26 09:57:25 -0500
committerGitHub <noreply@github.com>2020-01-26 09:57:25 -0500
commit96e5f476c3f7f44d0b299bc6043f3fd88769bd8b (patch)
tree5aadd86ef359eb847bf842f9594690737f0e67c4 /lib/std/buffer.zig
parent4e9b1f5479e3b7ce47d059e0e6f3d62cd4ee7254 (diff)
parent3839ea89785856bbed0624a6a18eb6e5acfb46c3 (diff)
downloadzig-96e5f476c3f7f44d0b299bc6043f3fd88769bd8b.tar.gz
zig-96e5f476c3f7f44d0b299bc6043f3fd88769bd8b.zip
Merge pull request #4264 from ziglang/layneson-cpus_and_features
Add support for target details (CPUs and their supported features)
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 {