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

ItemInfo

Public Struct
std.zig.Zir.Inst.SwitchBlock.ItemInfo
pub const ItemInfo = packed struct(u32)

Fields

kind: ItemInfo.Kind
data: u30

Types

Functions

pub fn wrap(unwrapped: ItemInfo.Unwrapped) ItemInfo
pub fn unwrap(item_info: ItemInfo) ItemInfo.Unwrapped
pub fn bodyLen(item_info: ItemInfo) ?u32

File

zig/Zir.zig:3428
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
        pub const ItemInfo = packed struct(u32) {
            kind: ItemInfo.Kind,
            data: u30,

            pub const Kind = enum(u2) {
                enum_literal,
                error_value,
                body_len,
                under,
            };

            pub const Unwrapped = union(ItemInfo.Kind) {
                enum_literal: Zir.NullTerminatedString,
                error_value: Zir.NullTerminatedString,
                body_len: u32,
                under,
            };

            pub fn wrap(unwrapped: ItemInfo.Unwrapped) ItemInfo {
                const data_uncasted: u32 = switch (unwrapped) {
                    .enum_literal => |str_index| @backingInt(str_index),
                    .error_value => |str_index| @backingInt(str_index),
                    .body_len => |body_len| body_len,
                    .under => 0,
                };
                return .{ .kind = unwrapped, .data = @intCast(data_uncasted) };
            }

            pub fn unwrap(item_info: ItemInfo) ItemInfo.Unwrapped {
                return switch (item_info.kind) {
                    .enum_literal => .{ .enum_literal = @fromBackingInt(@intCast(item_info.data)) },
                    .error_value => .{ .error_value = @fromBackingInt(@intCast(item_info.data)) },
                    .body_len => .{ .body_len = item_info.data },
                    .under => .under,
                };
            }

            pub fn bodyLen(item_info: ItemInfo) ?u32 {
                return if (item_info.kind == .body_len) item_info.data else null;
            }
        }