simplify catch
This commit is contained in:
parent
988ab9f6d4
commit
9487194c95
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user