mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 15:42:49 +00:00
Allow BoundArray to be default initialized
This commit is contained in:
parent
349a7cc272
commit
a5ac138ae2
@ -18,14 +18,14 @@ const testing = std.testing;
|
||||
pub fn BoundedArray(comptime T: type, comptime capacity: usize) type {
|
||||
return struct {
|
||||
const Self = @This();
|
||||
buffer: [capacity]T,
|
||||
buffer: [capacity]T = undefined,
|
||||
len: usize = 0,
|
||||
|
||||
/// Set the actual length of the slice.
|
||||
/// Returns error.Overflow if it exceeds the length of the backing array.
|
||||
pub fn init(len: usize) !Self {
|
||||
if (len > capacity) return error.Overflow;
|
||||
return Self{ .buffer = undefined, .len = len };
|
||||
return Self{ .len = len };
|
||||
}
|
||||
|
||||
/// View the internal array as a mutable slice whose size was previously set.
|
||||
|
Loading…
Reference in New Issue
Block a user