fn parseNum(text: []const u8) error text: []const u8143
144
145
146
147
148
149
150
151fn parseNum(text: []const u8) error{ InvalidVersion, Overflow }!usize {
// Leading zeroes are not allowed.
if (text.len > 1 and text[0] == '0') return error.InvalidVersion;
return std.fmt.parseUnsigned(usize, text, 10) catch |err| switch (err) {
error.InvalidCharacter => return error.InvalidVersion,
error.Overflow => |e| return e,
};
}