diff options
| author | tgschultz <tgschultz@gmail.com> | 2018-05-30 08:26:13 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-30 08:26:13 -0500 |
| commit | 8174f972a779384b287528e46ea086c714ce5553 (patch) | |
| tree | 02e919ffd9a783abb5b984aaefd9c4b03f608e8b /std/buffer.zig | |
| parent | 8c1872543c8cf76215cc4bf3ced4637bb1065a4e (diff) | |
| parent | 15302e84a45a04cfe94a8842318f02a608055962 (diff) | |
| download | zig-8174f972a779384b287528e46ea086c714ce5553.tar.gz zig-8174f972a779384b287528e46ea086c714ce5553.zip | |
Merge pull request #2 from ziglang/master
sync with ziglang
Diffstat (limited to 'std/buffer.zig')
| -rw-r--r-- | std/buffer.zig | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/std/buffer.zig b/std/buffer.zig index 42fec7f988..90d63719e3 100644 --- a/std/buffer.zig +++ b/std/buffer.zig @@ -31,9 +31,7 @@ pub const Buffer = struct { /// * ::replaceContentsBuffer /// * ::resize pub fn initNull(allocator: &Allocator) Buffer { - return Buffer { - .list = ArrayList(u8).init(allocator), - }; + return Buffer{ .list = ArrayList(u8).init(allocator) }; } /// Must deinitialize with deinit. @@ -45,9 +43,7 @@ pub const Buffer = struct { /// allocated with `allocator`. /// Must deinitialize with deinit. pub fn fromOwnedSlice(allocator: &Allocator, slice: []u8) Buffer { - var self = Buffer { - .list = ArrayList(u8).fromOwnedSlice(allocator, slice), - }; + var self = Buffer{ .list = ArrayList(u8).fromOwnedSlice(allocator, slice) }; self.list.append(0); return self; } @@ -57,11 +53,10 @@ pub const Buffer = struct { pub fn toOwnedSlice(self: &Buffer) []u8 { const allocator = self.list.allocator; const result = allocator.shrink(u8, self.list.items, self.len()); - *self = initNull(allocator); + self.* = initNull(allocator); return result; } - pub fn deinit(self: &Buffer) void { self.list.deinit(); } |
