DoxigAlpha

toOwnedSliceSentinel

The caller owns the returned memory. Empties this ArrayList.

Function parameters

Parameters

#
self:*Self
sentinel:T

Deprecated.

Functions

#
Managed
Deprecated.
AlignedManaged
Deprecated.
Aligned
A contiguous, growable list of arbitrarily aligned items in memory.

Source

Implementation

#
pub fn toOwnedSliceSentinel(self: *Self, 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(self.items.len + 1);
    self.appendAssumeCapacity(sentinel);
    const result = try self.toOwnedSlice();
    return result[0 .. result.len - 1 :sentinel];
}