Skip to content

Commit

Permalink
Revert "Buffer.toSliceCopy"
Browse files Browse the repository at this point in the history
This reverts commit c58f5a4.
  • Loading branch information
thejoshwolfe committed Jan 16, 2018
1 parent c58f5a4 commit 24c2ff5
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions std/buffer.zig
Expand Up @@ -146,16 +146,6 @@ pub const Buffer = struct {
pub fn ptr(self: &const Buffer) -> &u8 {
return self.list.items.ptr;
}

/// Returns a copy of this buffer's toSlice() contents
/// allocated exactly to size.
/// This method uses the provided allocator instead of
/// this object's own allocator to allocate the new array.
pub fn toSliceCopy(self: &Buffer, allocator: &Allocator) -> %[]u8 {
var result = try allocator.alloc(u8, self.len());
mem.copy(u8, result, self.toSliceConst());
return result;
}
};

test "simple Buffer" {
Expand All @@ -178,12 +168,3 @@ test "simple Buffer" {
try buf2.resize(4);
assert(buf.startsWith(buf2.toSliceConst()));
}

test "Buffer.toSliceCopy" {
var buffer = try Buffer.init(debug.global_allocator, "abc");
var copy = try buffer.toSliceCopy(debug.global_allocator);
buffer.shrink(0);
try buffer.append("xyz");
assert(mem.eql(u8, buffer.toSliceConst(), "xyz"));
assert(mem.eql(u8, copy, "abc"));
}

0 comments on commit 24c2ff5

Please sign in to comment.