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 standard library.
std › zon › Serializer › checkValueDepth Private Function checkValueDepth Doc Source Private Function std.zon.Serializer.checkValueDepth
fn checkValueDepth (val : anytype , depth : usize ) error Params File zon/Serializer.zig: 858
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886 fn checkValueDepth (val : anytype , depth : usize ) error {ExceededMaxDepth }!void {
if (depth == 0 ) return error .ExceededMaxDepth ;
const child_depth = depth - 1 ;
switch (@typeInfo (@TypeOf (val ))) {
.pointer => |pointer | switch (pointer .size ) {
.one => try checkValueDepth (val .*, child_depth ),
.slice => for (val ) |item | {
try checkValueDepth (item , child_depth );
},
.c , .many => {},
},
.array => for (val ) |item | {
try checkValueDepth (item , child_depth );
},
.@"struct" => |@"struct" | inline for (@"struct" .field_names ) |field_name | {
try checkValueDepth (@field (val , field_name ), child_depth );
},
.@"union" => |@"union" | if (@"union" .tag_type == null ) {
return ;
} else switch (val ) {
inline else => |payload | {
return checkValueDepth (payload , child_depth );
},
},
.optional => if (val ) |inner | try checkValueDepth (inner , child_depth ),
else => {},
}
}