zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit a83fb9289fe82a0e4f5c228342e79d559af69bc3 (tree)
parent e24dcd2707b5956cd53d4b38dc3ac6be0cf0a264
Author: Rohlem <rohlemF@gmail.com>
Date:   Fri, 19 Nov 2021 12:08:28 +0100

std.bounded_array: fix `self` parameter type in `constSlice`

Because `.buffer` is an inline array field, we actually require `self` to be passed as a pointer.
If the compiler decided to pass the object by copying, we would return a pointer to to-be-destroyed stack memory.

Diffstat:
Mlib/std/bounded_array.zig | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/std/bounded_array.zig b/lib/std/bounded_array.zig @@ -34,7 +34,7 @@ pub fn BoundedArray(comptime T: type, comptime capacity: usize) type { } /// View the internal array as a constant slice whose size was previously set. - pub fn constSlice(self: Self) []const T { + pub fn constSlice(self: *const Self) []const T { return self.buffer[0..self.len]; }