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.

Term

Child.Term
pub const Term = union(enum)

File

lib/std/process/Child.zig:94

Code

pub const Term = union(enum) {
    exited: u8,
    signal: std.posix.SIG,
    stopped: std.posix.SIG,
    unknown: u32,

    pub fn success(t: Term) bool {
        return switch (t) {
            .exited => |code| code == 0,
            else => false,
        };
    }

    pub fn format(t: Term, w: *Io.Writer) Io.Writer.Error!void {
        switch (t) {
            .exited => |code| return w.print("exited with code {d}", .{code}),
            .signal => |sig| return w.print("terminated with signal {t}", .{sig}),
            .stopped => |sig| return w.print("stopped with signal {t}", .{sig}),
            .unknown => return w.writeAll("terminated unexpectedly"),
        }
    }
}