pub fn AbsorbSentinel(comptime Pointer: type) type 1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121pub fn AbsorbSentinel(comptime Pointer: type) type {
const info = @typeInfo(Pointer).pointer;
switch (info.size) {
.slice => return @Pointer(.slice, info.attrs, info.child, null),
.one => {
const child_info = @typeInfo(info.child).array;
if (child_info.sentinel_ptr == null) {
return Pointer;
} else {
return @Pointer(.one, info.attrs, [child_info.len + 1]child_info.child, null);
}
},
else => unreachable,
}
}
Given a pointer type, removes the sentinel if present, returning an equivalent pointer type with no sentinel