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.
asciiToInteger
stdlib.asciiToInteger
fnasciiToInteger(comptimeT: type, buf: [*:0]constu8) T
fnasciiToInteger(comptimeT: type, buf: [*:0]constu8) T {
comptimeassert(std.math.isPowerOfTwo(@bitSizeOf(T)));
varcurrent = buf;
while (std.ascii.isWhitespace(current[0])) : (current += 1) {}
// The behaviour *is* undefined if the result cannot be represented
// but as they are usually called with untrusted input we can just handle overflow gracefully.
if (current[0] == '-') returnparseDigitsWithSignGenericCharacter(T, u8, current + 1, null, 10, .neg) catchstd.math.minInt(T);
if (current[0] == '+') current += 1;
returnparseDigitsWithSignGenericCharacter(T, u8, current, null, 10, .pos) catchstd.math.maxInt(T);
}