aboutsummaryrefslogtreecommitdiff
path: root/lib/std/meta.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-01-15 17:34:12 +0000
committermlugg <mlugg@mlugg.co.uk>2025-01-16 12:49:58 +0000
commit9804cc8bc6fe83b2a0cd5b61b8d2fc5d458cb221 (patch)
treed2f7a675b37c8f94db9b1015589a3b37805e2ac6 /lib/std/meta.zig
parent89a9cabafd745034871ea014b06bd3bad0505f4a (diff)
downloadzig-9804cc8bc6fe83b2a0cd5b61b8d2fc5d458cb221.tar.gz
zig-9804cc8bc6fe83b2a0cd5b61b8d2fc5d458cb221.zip
all: update to `std.builtin.Type.{Pointer,Array,StructField}` field renames
Diffstat (limited to 'lib/std/meta.zig')
-rw-r--r--lib/std/meta.zig25
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index 5d3c9f34be..08c8589682 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -132,21 +132,12 @@ test Elem {
/// Result is always comptime-known.
pub inline fn sentinel(comptime T: type) ?Elem(T) {
switch (@typeInfo(T)) {
- .array => |info| {
- const sentinel_ptr = info.sentinel orelse return null;
- return @as(*const info.child, @ptrCast(sentinel_ptr)).*;
- },
+ .array => |info| return info.sentinel(),
.pointer => |info| {
switch (info.size) {
- .many, .slice => {
- const sentinel_ptr = info.sentinel orelse return null;
- return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
- },
+ .many, .slice => return info.sentinel(),
.one => switch (@typeInfo(info.child)) {
- .array => |array_info| {
- const sentinel_ptr = array_info.sentinel orelse return null;
- return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
- },
+ .array => |array_info| return array_info.sentinel(),
else => {},
},
else => {},
@@ -190,11 +181,11 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
.array = .{
.len = array_info.len,
.child = array_info.child,
- .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
+ .sentinel_ptr = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
},
}),
.is_allowzero = info.is_allowzero,
- .sentinel = info.sentinel,
+ .sentinel_ptr = info.sentinel_ptr,
},
}),
else => {},
@@ -208,7 +199,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
.address_space = info.address_space,
.child = info.child,
.is_allowzero = info.is_allowzero,
- .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
+ .sentinel_ptr = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
},
}),
else => {},
@@ -226,7 +217,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
.address_space = ptr_info.address_space,
.child = ptr_info.child,
.is_allowzero = ptr_info.is_allowzero,
- .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
+ .sentinel_ptr = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
},
}),
},
@@ -1018,7 +1009,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type {
tuple_fields[i] = .{
.name = std.fmt.bufPrintZ(&num_buf, "{d}", .{i}) catch unreachable,
.type = T,
- .default_value = null,
+ .default_value_ptr = null,
.is_comptime = false,
.alignment = 0,
};