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:
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user