From 106e3cd96361201c157662399c462d0317a6284b Mon Sep 17 00:00:00 2001 From: Lee Cannon Date: Sun, 29 May 2022 18:17:43 +0100 Subject: [PATCH] `std.math.cast` returns optional --- src/requests.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/requests.zig b/src/requests.zig index 3b99335..cf5ec2d 100644 --- a/src/requests.zig +++ b/src/requests.zig @@ -114,11 +114,11 @@ fn fromDynamicTreeInternal(arena: *std.heap.ArenaAllocator, value: std.json.Valu if (value != .Integer) return error.MalformedJson; out.* = std.meta.intToEnum( T, - std.math.cast(TagType, value.Integer) catch return error.MalformedJson, + std.math.cast(TagType, value.Integer) orelse return error.MalformedJson, ) catch return error.MalformedJson; } else if (comptime std.meta.trait.is(.Int)(T)) { if (value != .Integer) return error.MalformedJson; - out.* = std.math.cast(T, value.Integer) catch return error.MalformedJson; + out.* = std.math.cast(T, value.Integer) orelse return error.MalformedJson; } else switch (T) { bool => { if (value != .Bool) return error.MalformedJson;