diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-01-15 16:57:04 +0000 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-01-16 12:49:58 +0000 |
| commit | 89a9cabafd745034871ea014b06bd3bad0505f4a (patch) | |
| tree | 3d731785b1c66bbbd947911802f6f1c4837490b7 /lib/std/meta | |
| parent | 0cc9d68b77b31c6502da80ce7e6dabaf9316ca48 (diff) | |
| download | zig-89a9cabafd745034871ea014b06bd3bad0505f4a.tar.gz zig-89a9cabafd745034871ea014b06bd3bad0505f4a.zip | |
std.builtin.Type: improve ergonomics of `*const anyopaque` fields
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.
Diffstat (limited to 'lib/std/meta')
0 files changed, 0 insertions, 0 deletions
