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.

SignOf

math.SignOf
fn SignOf(T: type) type

File

lib/std/math.zig:1764

Code

fn SignOf(T: type) type {
    return switch (@typeInfo(T)) {
        .comptime_int, .comptime_float => comptime_int,
        .int => IntFittingRange(@max(minInt(T), -1), @min(maxInt(T), 1)),
        .float => IntFittingRange(-1, 1),
        .vector => |vec| @Vector(vec.len, SignOf(vec.child)),
        else => @compileError("Expected an int, float, or a vector of one, found " ++ @typeName(T)),
    };
}