pub const Array = struct len: comptime_intchild: typesentinel_ptr: ?*const anyopaqueThe type of the sentinel is the element type of the array, which is the value of the child field in this struct. However there is no way to refer to that type here, so we use *const anyopaque. See also: sentinel.
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739 pub const Array = struct {
len: comptime_int,
child: type,
/// The type of the sentinel is the element type of the array, which is
/// the value of the `child` field in this struct. However there is no way
/// to refer to that type here, so we use `*const anyopaque`.
/// See also: `sentinel`.
sentinel_ptr: ?*const anyopaque,
/// Loads the array type's sentinel value from `sentinel_ptr`.
/// Returns `null` if the array type has no sentinel.
pub inline fn sentinel(comptime arr: Array) ?arr.child {
const sp: *const arr.child = @ptrCast(@alignCast(arr.sentinel_ptr orelse return null));
return sp.*;
}
}
This data structure is used by the Zig language code generation and therefore must be kept in sync with the compiler implementation.