authorgravatar for rohlemF@gmail.comRohlem <rohlemF@gmail.com> 2021-11-19 12:08:28+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-11-20 02:35:36-05:00
loga83fb9289fe82a0e4f5c228342e79d559af69bc3
tree71b4c0c745d107421cc60a23431292a175d4c1e9
parente24dcd2707b5956cd53d4b38dc3ac6be0cf0a264

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.

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

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