Commit a83fb9289f

Rohlem <rohlemF@gmail.com>
2021-11-19 12:08:28
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 parent e24dcd2
Changed files (1)
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];
         }