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 Enum

OptionalString

Public Enum
std.Build.Configuration.OptionalString
pub const OptionalString = enum(u32)

Points into string_bytes, null-terminated.

Functions

pub fn init(s: String) OptionalString
pub fn unwrap(this: @This()) ?String
pub fn slice(this: @This(), c: *const Configuration) ?[: 0]const u8

File

Build/Configuration.zig:1918
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
pub const OptionalString = enum(u32) {
    empty = 0,
    /// The string "root".
    root = 1,
    none = max_u32,
    _,

    pub fn init(s: String) OptionalString {
        const result: OptionalString = @fromBackingInt(@intCast(@backingInt(s)));
        assert(result != .none);
        return result;
    }

    pub fn unwrap(this: @This()) ?String {
        if (this == .none) return null;
        return @fromBackingInt(@intCast(@backingInt(this)));
    }

    pub fn slice(this: @This(), c: *const Configuration) ?[:0]const u8 {
        return (unwrap(this) orelse return null).slice(c);
    }
}