mirror of
https://github.com/ziglang/zig.git
synced 2025-02-13 08:00:20 +00:00
Fix error handling in Buffer::fromOwnedSlice (#1082)
This commit is contained in:
parent
39fa313ad8
commit
1a9d2f3aae
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user