Zig 0.17.0-dev (Split by item)

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 library itself.

DefaultingBool

Configuration.DefaultingBool
pub const DefaultingBool = enum(u2)

File

lib/std/Build/Configuration.zig:1989

Code

pub const DefaultingBool = enum(u2) {
    false,
    true,
    default,

    pub fn init(b: ?bool) DefaultingBool {
        return switch (b orelse return .default) {
            false => .false,
            true => .true,
        };
    }

    pub fn toBool(db: DefaultingBool) ?bool {
        return switch (db) {
            .false => false,
            .true => true,
            .default => null,
        };
    }
}