mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 14:55:25 +00:00
For representing struct field default values and array/pointer type sentinel values, we use `*const anyopaque`, since there is no way for `std.builtin.Type.StructField` etc to refer back to its `type` field. However, when introspecting a type, this is quite awkward due to the pointer casts necessary. As such, this commit renames the `sentinel` fields to `sentinel_ptr`, and the `default_value` field to `default_value_ptr`, and introduces helper methods `sentinel()` and `defaultValue()` to load the values. These methods are marked as `inline` because their return value, which is always comptime-known, is very often required at comptime by use sites, so this avoids having to annotate such calls with `comptime`. This is a breaking change, although note that 0.14.0 is already a breaking release for all users of `std.builtin.Type` due to the union fields being renamed.