authorgravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2018-01-16 13:45:34-07:00
committergravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2018-01-16 13:45:34-07:00
log24c2ff5caea15d3d6953414cd4a984993e8fa36e
treee9ed503ecbeb4b5ce2dcbefd953670d834fc5cb6
parentc58f5a4742156c09e215533ae274f9f991e287a7

Revert "Buffer.toSliceCopy"

This reverts commit c58f5a4742156c09e215533ae274f9f991e287a7.

1 files changed, 0 insertions(+), 19 deletions(-)

std/buffer.zig-19
...@@ -146,16 +146,6 @@ pub const Buffer = struct {...@@ -146,16 +146,6 @@ pub const Buffer = struct {
146 pub fn ptr(self: &const Buffer) -> &u8 {146 pub fn ptr(self: &const Buffer) -> &u8 {
147 return self.list.items.ptr;147 return self.list.items.ptr;
148 }148 }
149
150 /// Returns a copy of this buffer's toSlice() contents
151 /// allocated exactly to size.
152 /// This method uses the provided allocator instead of
153 /// this object's own allocator to allocate the new array.
154 pub fn toSliceCopy(self: &Buffer, allocator: &Allocator) -> %[]u8 {
155 var result = try allocator.alloc(u8, self.len());
156 mem.copy(u8, result, self.toSliceConst());
157 return result;
158 }
159};149};
160150
161test "simple Buffer" {151test "simple Buffer" {
...@@ -178,12 +168,3 @@ test "simple Buffer" {...@@ -178,12 +168,3 @@ test "simple Buffer" {
178 try buf2.resize(4);168 try buf2.resize(4);
179 assert(buf.startsWith(buf2.toSliceConst()));169 assert(buf.startsWith(buf2.toSliceConst()));
180}170}
181
182test "Buffer.toSliceCopy" {
183 var buffer = try Buffer.init(debug.global_allocator, "abc");
184 var copy = try buffer.toSliceCopy(debug.global_allocator);
185 buffer.shrink(0);
186 try buffer.append("xyz");
187 assert(mem.eql(u8, buffer.toSliceConst(), "xyz"));
188 assert(mem.eql(u8, copy, "abc"));
189}