Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reflect: use orelse for less verbose clode
Browse files Browse the repository at this point in the history
Signed-off-by: Francis Bouvier <[email protected]>
francisbouvier committed Oct 6, 2023

Unverified

This user has not yet uploaded their public signing key.
1 parent 5079c22 commit 3bd97ce
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/reflect.zig
Original file line number Diff line number Diff line change
@@ -108,16 +108,13 @@ pub const Type = struct {
pub fn variadic(comptime T: type) !?Type {
std.debug.assert(@inComptime());

if (Type._variadic(T)) |tt| {
const tt = Type._variadic(T) orelse return null;

// avoid infinite calls
if (Type._variadic(tt) != null) {
return error.TypeVariadicNested;
}

return try Type.reflect(tt, null);
// avoid infinite calls
if (Type._variadic(tt) != null) {
return error.TypeVariadicNested;
}
return null;
return try Type.reflect(tt, null);
}

// check that user-defined types have been provided as an API

0 comments on commit 3bd97ce

Please sign in to comment.