pub const Struct = struct is_tuple: boollayout: ContainerLayoutbacking_integer: ?typeAlways null if layout != .@"packed".
field_names: []const [:0]const u8field_types: []const typeGuaranteed to have the same length as field_names.
field_attrs: []const FieldAttributesGuaranteed to have the same length as field_names.
decl_names: []const [:0]const u8751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785 pub const Struct = struct {
is_tuple: bool,
layout: ContainerLayout,
/// Always `null` if `layout != .@"packed"`.
backing_integer: ?type,
field_names: []const [:0]const u8,
/// Guaranteed to have the same length as `field_names`.
field_types: []const type,
/// Guaranteed to have the same length as `field_names`.
field_attrs: []const FieldAttributes,
decl_names: []const [:0]const u8,
pub const FieldAttributes = struct {
@"comptime": bool = false,
/// `null` means the field alignment is not explicitly specified. The field will still
/// be aligned to at least `@alignOf` the field type.
@"align": ?usize = null,
/// The type of the default value is the type of this struct field. However, that type
/// is not known here, so we use a type-erased pointer instead, which must be cast to
/// a pointer to the field type.
///
/// See also: `defaultValue`.
default_value_ptr: ?*const anyopaque = null,
/// Loads the field's default value from `default_value_ptr`.
/// `FieldType` must exactly match the corresponding element of `Struct.field_types`.
/// Returns `null` if the field has no default value.
pub inline fn defaultValue(comptime attrs: FieldAttributes, comptime FieldType: type) ?FieldType {
const dp: *const FieldType = @ptrCast(@alignCast(attrs.default_value_ptr orelse return null));
return dp.*;
}
};
}
This data structure is used by the Zig language code generation and therefore must be kept in sync with the compiler implementation.