aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fmt/parse_float.zig
diff options
context:
space:
mode:
authorDmitry Matveyev <greenfork.lists@yandex.com>2021-08-20 17:52:48 +0600
committerGitHub <noreply@github.com>2021-08-20 14:52:48 +0300
commitb2e970d157343919ea2be44b3ebe4c519324bd4e (patch)
tree0e2f22cd16d360e36cdf9edbeafb5b1aa882e49e /lib/std/fmt/parse_float.zig
parentcfb2827b0a9efaf3937db27dbe3352cbb612466b (diff)
downloadzig-b2e970d157343919ea2be44b3ebe4c519324bd4e.tar.gz
zig-b2e970d157343919ea2be44b3ebe4c519324bd4e.zip
std.json: Add support for recursive objects to std.json.parse (#9307)
* Add support for recursive objects to std.json.parse * Remove previously defined error set * Try with function which returns an error set * Don't analyze already inferred types * Add comptime to inferred_type parameter * Make ParseInternalError to accept only a single argument * Add public `ParseError` for `parse` function * Use error.Foo syntax for errors instead of a named error set * Better formatting * Update to latest code changes
Diffstat (limited to 'lib/std/fmt/parse_float.zig')
-rw-r--r--lib/std/fmt/parse_float.zig4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig
index 6178398b17..ed6224b4b9 100644
--- a/lib/std/fmt/parse_float.zig
+++ b/lib/std/fmt/parse_float.zig
@@ -349,7 +349,9 @@ fn caseInEql(a: []const u8, b: []const u8) bool {
return true;
}
-pub fn parseFloat(comptime T: type, s: []const u8) !T {
+pub const ParseFloatError = error{InvalidCharacter};
+
+pub fn parseFloat(comptime T: type, s: []const u8) ParseFloatError!T {
if (s.len == 0 or (s.len == 1 and (s[0] == '+' or s[0] == '-'))) {
return error.InvalidCharacter;
}