simplify catch

This commit is contained in:
Motiejus Jakštys 2022-02-20 09:19:59 +02:00 committed by Motiejus Jakštys
parent 988ab9f6d4
commit 9487194c95

View File

@ -48,13 +48,11 @@ pub const UserWriter = struct {
const fromUserErr = error{InvalidRecord};
pub fn downCast(comptime T: type, n: u64) fromUserErr!T {
if (std.math.cast(T, n)) |result| {
return result;
} else |err| switch (err) {
return std.math.cast(T, n) catch |err| switch (err) {
error.Overflow => {
return error.InvalidRecord;
},
}
};
}
pub fn appendUser(self: *UserWriter, user: User) !void {