Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › zon/ › Serializer.zig › typeIsRecursiveInner
typeIsRecursiveInner
Serializer.typeIsRecursiveInner
fn typeIsRecursiveInner (comptime T : type , comptime prev_visited : []const type ) bool
File
Code
fn typeIsRecursiveInner (comptime T : type , comptime prev_visited : []const type ) bool {
for (prev_visited ) |V | {
if (V == T ) return true ;
}
const visited = prev_visited ++ .{T };
return switch (@typeInfo (T )) {
.pointer => |pointer | typeIsRecursiveInner (pointer .child , visited ),
.optional => |optional | typeIsRecursiveInner (optional .child , visited ),
.array => |array | typeIsRecursiveInner (array .child , visited ),
.vector => |vector | typeIsRecursiveInner (vector .child , visited ),
.@"struct" => |@"struct" | for (@"struct" .field_types ) |field_type | {
if (typeIsRecursiveInner (field_type , visited )) break true ;
} else false ,
.@"union" => |@"union" | inline for (@"union" .field_types ) |field_type | {
if (typeIsRecursiveInner (field_type , visited )) break true ;
} else false ,
else => false ,
};
}