authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2022-01-12 16:27:38+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-12 13:17:01-05:00
loga5ac138ae241dad947eab4c3b6c8782d4e95bbe4
tree16a6b4a7da037ab5a574d47ea42158efc1a71776
parent349a7cc272593a61c98c8259ff8eeb0adeaabf2e

Allow BoundArray to be default initialized


1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/bounded_array.zig+2-2
...@@ -18,14 +18,14 @@ const testing = std.testing;...@@ -18,14 +18,14 @@ const testing = std.testing;
18pub fn BoundedArray(comptime T: type, comptime capacity: usize) type {18pub fn BoundedArray(comptime T: type, comptime capacity: usize) type {
19 return struct {19 return struct {
20 const Self = @This();20 const Self = @This();
21 buffer: [capacity]T,21 buffer: [capacity]T = undefined,
22 len: usize = 0,22 len: usize = 0,
2323
24 /// Set the actual length of the slice.24 /// Set the actual length of the slice.
25 /// Returns error.Overflow if it exceeds the length of the backing array.25 /// Returns error.Overflow if it exceeds the length of the backing array.
26 pub fn init(len: usize) !Self {26 pub fn init(len: usize) !Self {
27 if (len > capacity) return error.Overflow;27 if (len > capacity) return error.Overflow;
28 return Self{ .buffer = undefined, .len = len };28 return Self{ .len = len };
29 }29 }
3030
31 /// View the internal array as a mutable slice whose size was previously set.31 /// View the internal array as a mutable slice whose size was previously set.