| ... | @@ -566,7 +566,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { | ... | @@ -566,7 +566,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 566 | /// This can be useful for writing directly into an ArrayList. | 566 | /// This can be useful for writing directly into an ArrayList. |
| 567 | /// Note that such an operation must be followed up with a direct | 567 | /// Note that such an operation must be followed up with a direct |
| 568 | /// modification of `self.items.len`. | 568 | /// modification of `self.items.len`. |
| 569 | pub fn unusedCapacitySlice(self: Self) Slice { | 569 | pub fn unusedCapacitySlice(self: Self) []T { |
| 570 | return self.allocatedSlice()[self.items.len..]; | 570 | return self.allocatedSlice()[self.items.len..]; |
| 571 | } | 571 | } |
| 572 | | 572 | |
| ... | @@ -1193,7 +1193,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ | ... | @@ -1193,7 +1193,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 1193 | /// This can be useful for writing directly into an ArrayList. | 1193 | /// This can be useful for writing directly into an ArrayList. |
| 1194 | /// Note that such an operation must be followed up with a direct | 1194 | /// Note that such an operation must be followed up with a direct |
| 1195 | /// modification of `self.items.len`. | 1195 | /// modification of `self.items.len`. |
| 1196 | pub fn unusedCapacitySlice(self: Self) Slice { | 1196 | pub fn unusedCapacitySlice(self: Self) []T { |
| 1197 | return self.allocatedSlice()[self.items.len..]; | 1197 | return self.allocatedSlice()[self.items.len..]; |
| 1198 | } | 1198 | } |
| 1199 | | 1199 | |
| ... | @@ -2242,3 +2242,10 @@ test "return OutOfMemory when capacity would exceed maximum usize integer value" | ... | @@ -2242,3 +2242,10 @@ test "return OutOfMemory when capacity would exceed maximum usize integer value" |
| 2242 | try testing.expectError(error.OutOfMemory, list.ensureUnusedCapacity(2)); | 2242 | try testing.expectError(error.OutOfMemory, list.ensureUnusedCapacity(2)); |
| 2243 | } | 2243 | } |
| 2244 | } | 2244 | } |
| | 2245 | |
| | 2246 | test "ArrayListAligned with non-native alignment compiles unusedCapabitySlice" { |
| | 2247 | var list = ArrayListAligned(u8, 4).init(testing.allocator); |
| | 2248 | defer list.deinit(); |
| | 2249 | try list.appendNTimes(1, 4); |
| | 2250 | _ = list.unusedCapacitySlice(); |
| | 2251 | } |