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.

Alignment

Stored as a power-of-two, with one special value to indicate none.

Configuration.Alignment
pub const Alignment = enum(u6)

File

lib/std/Build/Configuration.zig:1965

Code

pub const Alignment = enum(u6) {
    @"1" = 0,
    @"2" = 1,
    @"4" = 2,
    @"8" = 3,
    @"16" = 4,
    @"32" = 5,
    @"64" = 6,
    none = std.math.maxInt(u6),
    _,

    pub fn init(optional_alignment: ?std.mem.Alignment) @This() {
        const a = optional_alignment orelse return .none;
        return @fromBackingInt(@intCast(@backingInt(a)));
    }

    pub fn toBytes(a: @This()) ?u64 {
        return switch (a) {
            .none => null,
            else => @as(u64, 1) << @backingInt(a),
        };
    }
}