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 Function

data

Public Function
std.Build.Configuration.Storage.data
pub fn data(buffer: []const u32, i: *usize, comptime T: type) T

Params

  • buffer: []const u32
  • i: *usize
  • T: type

File

Build/Configuration.zig:2771
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
    pub fn data(buffer: []const u32, i: *usize, comptime T: type) T {
        switch (@typeInfo(T)) {
            .@"struct" => |info| {
                var result: T = undefined;
                inline for (info.field_names, info.field_types) |field_name, field_type| {
                    @field(result, field_name) = dataField(buffer, i, &result, field_type);
                }
                return result;
            },
            .@"union" => |info| {
                const flags: T.Flags = @bitCast(buffer[i.*]);
                return switch (flags.tag) {
                    inline else => |comptime_tag| @unionInit(
                        T,
                        @tagName(comptime_tag),
                        data(buffer, i, info.field_types[@backingInt(comptime_tag)]),
                    ),
                };
            },
            else => comptime unreachable,
        }
    }