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.
This commit is contained in:
Rohlem 2021-11-19 12:08:28 +01:00 committed by Andrew Kelley
parent e24dcd2707
commit a83fb9289f

View File

@ -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];
}