If the provided slice is not sentinel terminated, do nothing and return that slice. If it is sentinel-terminated, return a non-sentinel-terminated slice with the length increased by one to include the absorbed sentinel element.
pub fn absorbSentinel(slice: anytype) AbsorbSentinelReturnType(@TypeOf(slice))
pub fn absorbSentinel(slice: anytype) AbsorbSentinelReturnType(@TypeOf(slice)) {
const info = @typeInfo(@TypeOf(slice)).pointer;
comptime assert(info.size == .slice);
if (info.sentinel_ptr == null) {
return slice;
} else {
return slice.ptr[0 .. slice.len + 1];
}
}