Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Struct

Array

Public Struct
std.lang.Type.Array
pub const Array = struct

This data structure is used by the Zig language code generation and therefore must be kept in sync with the compiler implementation.

Fields

len: comptime_int
child: type
sentinel_ptr: ?*const anyopaque

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.

Functions

pub inline fn sentinel(comptime arr: Array) ?arr.child

File

lang.zig:723
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.*;
        }
    }