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 Function

isPrimitive

Public Function
std.zig.primitives.isPrimitive
pub fn isPrimitive(name: []const u8) bool

Returns true if a name matches a primitive type or value, excluding _. Integer type names like u8 or i32 are only matched for syntax, so this will still return true when they have an oversized bit count or leading zeroes.

Params

  • name: []const u8

File

zig/primitives.zig:42
42
43
44
45
46
47
48
49
50
51
52
pub fn isPrimitive(name: []const u8) bool {
    if (names.get(name) != null) return true;
    if (name.len < 2) return false;
    const first_c = name[0];
    if (first_c != 'i' and first_c != 'u') return false;
    for (name[1..]) |c| switch (c) {
        '0'...'9' => {},
        else => return false,
    };
    return true;
}