pub const FieldAttributes = struct @"comptime": bool = false@"align": ?usize = nullnull means the field alignment is not explicitly specified. The field will still be aligned to at least @alignOf the field type.
default_value_ptr: ?*const anyopaque = nullThe 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.
pub inline fn defaultValue(comptime attrs: FieldAttributes, comptime FieldType: type) ?FieldType765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784 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.*;
}
}