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.

AtomicOrdering

Builder.AtomicOrdering
pub const AtomicOrdering = enum(u3)

File

lib/std/zig/llvm/Builder.zig:7186

Code

pub const AtomicOrdering = enum(u3) {
    none = 0,
    unordered = 1,
    monotonic = 2,
    acquire = 3,
    release = 4,
    acq_rel = 5,
    seq_cst = 6,

    pub fn format(atomic_ordering: AtomicOrdering, w: *Writer) Writer.Error!void {
        return Prefixed.format(.{ .atomic_ordering = atomic_ordering, .prefix = "" }, w);
    }

    pub const Prefixed = struct {
        atomic_ordering: AtomicOrdering,
        prefix: []const u8,

        pub fn format(p: Prefixed, w: *Writer) Writer.Error!void {
            switch (p.atomic_ordering) {
                .none => return,
                else => {
                    var vecs: [2][]const u8 = .{ p.prefix, @tagName(p.atomic_ordering) };
                    return w.writeVecAll(&vecs);
                },
            }
        }
    };

    pub fn fmt(atomic_ordering: AtomicOrdering, prefix: []const u8) Prefixed {
        return .{ .atomic_ordering = atomic_ordering, .prefix = prefix };
    }
}