diff options
| author | Jimmi Holst Christensen <jhc@dismail.de> | 2022-01-12 16:27:38 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-01-12 13:17:01 -0500 |
| commit | a5ac138ae241dad947eab4c3b6c8782d4e95bbe4 (patch) | |
| tree | 16a6b4a7da037ab5a574d47ea42158efc1a71776 /lib/std/bounded_array.zig | |
| parent | 349a7cc272593a61c98c8259ff8eeb0adeaabf2e (diff) | |
| download | zig-a5ac138ae241dad947eab4c3b6c8782d4e95bbe4.tar.gz zig-a5ac138ae241dad947eab4c3b6c8782d4e95bbe4.zip | |
Allow BoundArray to be default initialized
Diffstat (limited to 'lib/std/bounded_array.zig')
| -rw-r--r-- | lib/std/bounded_array.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/std/bounded_array.zig b/lib/std/bounded_array.zig index bc5f196087..a7810697fc 100644 --- a/lib/std/bounded_array.zig +++ b/lib/std/bounded_array.zig @@ -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. |
