parseNum
Function parameters
Parameters
- text:[]const u8
Type definitions in this namespace
Types
Functions in this namespace
Functions
Source
Implementation
fn 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 => return error.Overflow,
};
}