mirror of
https://github.com/ziglang/zig.git
synced 2024-12-04 19:09:32 +00:00
parse_float: Error when a float is attempted to be parsed into an invalid type
Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
This commit is contained in:
parent
5a3eca5d4c
commit
b18b4db709
@ -12,6 +12,14 @@ pub const ParseFloatError = error{
|
||||
};
|
||||
|
||||
pub fn parseFloat(comptime T: type, s: []const u8) ParseFloatError!T {
|
||||
if (@typeInfo(T) != .Float) {
|
||||
@compileError("Cannot parse a float into a non-floating point type.");
|
||||
}
|
||||
|
||||
if (T == f80) {
|
||||
@compileError("TODO support parsing float to f80");
|
||||
}
|
||||
|
||||
if (s.len == 0) {
|
||||
return error.InvalidCharacter;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user