Fix error handling in Buffer::fromOwnedSlice (#1082)

This commit is contained in:
isaachier 2018-06-08 19:24:48 -04:00 committed by Andrew Kelley
parent 39fa313ad8
commit 1a9d2f3aae

View File

@ -41,9 +41,9 @@ pub const Buffer = struct {
/// Buffer takes ownership of the passed in slice. The slice must have been
/// allocated with `allocator`.
/// Must deinitialize with deinit.
pub fn fromOwnedSlice(allocator: *Allocator, slice: []u8) Buffer {
pub fn fromOwnedSlice(allocator: *Allocator, slice: []u8) !Buffer {
var self = Buffer{ .list = ArrayList(u8).fromOwnedSlice(allocator, slice) };
self.list.append(0);
try self.list.append(0);
return self;
}