pub fn toOwnedSliceSentinelAssert(self: *Self, comptime sentinel: T) SentinelSlice(sentinel) self: *Selfsentinel: T789
790
791
792
793
794 pub fn toOwnedSliceSentinelAssert(self: *Self, comptime sentinel: T) SentinelSlice(sentinel) {
std.debug.assert(self.items.len + 1 == self.capacity);
self.appendAssumeCapacity(sentinel);
const result = self.toOwnedSliceAssert();
return result[0 .. result.len - 1 :sentinel];
}
The caller owns the returned memory. ArrayList becomes empty. Asserts what the capacity is equal to the length + 1. Never invalidates element pointers.