toOwnedSliceSentinel
The caller owns the returned memory. ArrayList becomes empty.
Function parameters
Parameters
Deprecated.
Functions
- Managed
- Deprecated.
- AlignedManaged
- Deprecated.
- Aligned
- A contiguous, growable list of arbitrarily aligned items in memory.
Source
Implementation
pub fn toOwnedSliceSentinel(self: *Self, gpa: Allocator, comptime sentinel: T) Allocator.Error!SentinelSlice(sentinel) {
// This addition can never overflow because `self.items` can never occupy the whole address space
try self.ensureTotalCapacityPrecise(gpa, self.items.len + 1);
self.appendAssumeCapacity(sentinel);
const result = try self.toOwnedSlice(gpa);
return result[0 .. result.len - 1 :sentinel];
}