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 › json › static › fillDefaultStructValues Private Function fillDefaultStructValues Doc Source Private Function std.json.static.fillDefaultStructValues
fn fillDefaultStructValues (comptime T : type , r : *T , fields_seen : *[@typeInfo (T ).@"struct" .field_names .len ]bool ) !void Params T : type r : *T fields_seen : *[@typeInfo (T ).@"struct" .field_names .len ]bool File json/static.zig: 796
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812 fn fillDefaultStructValues (comptime T : type , r : *T , fields_seen : *[@typeInfo (T ).@"struct" .field_names .len ]bool ) !void {
const info = @typeInfo (T ).@"struct" ;
inline for (
info .field_names ,
info .field_types ,
info .field_attrs ,
0 ..,
) |field_name , field_type , field_attrs , i | {
if (!fields_seen [i ]) {
if (field_attrs .defaultValue (field_type )) |default | {
@field (r , field_name ) = default ;
} else {
return error .MissingField ;
}
}
}
}