Parses the string buf as a base 10 integer of type u16.
Unlike std.fmt.parseInt, does not allow the '_' character in buf.
fn parseBitCount(buf: []const u8) std.fmt.ParseIntError!u16
fn parseBitCount(buf: []const u8) std.fmt.ParseIntError!u16 {
if (buf.len == 0) return error.InvalidCharacter;
var x: u16 = 0;
for (buf) |c| {
const digit = switch (c) {
'0'...'9' => c - '0',
else => return error.InvalidCharacter,
};
if (x != 0) x = try std.math.mul(u16, x, 10);
x = try std.math.add(u16, x, digit);
}
return x;
}