Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Type Function

AbsorbSentinel

Public Type Function
std.meta.AbsorbSentinel
pub fn AbsorbSentinel(comptime Pointer: type) type

Given a pointer type, removes the sentinel if present, returning an equivalent pointer type with no sentinel

File

meta.zig:1107
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
pub 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,
    }
}