mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
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:
parent
e24dcd2707
commit
a83fb9289f
@ -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];
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user