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. Private Union

SwitchNonErr

Private Union
std.zig.AstGen.SwitchNonErr
const SwitchNonErr = union(enum)

Fields

none: none

A regular switch expression. Emits switch_block[_ref].

@"catch": @"catch"

eu catch |err| switch (err) { ... }

switch must not be labeled. Emits switch_block_err_union.

@"if": Ast.full.If

if (eu) |payload| { ... } else |err| switch (err) { ... }

switch must not be labeled. Emits switch_block_err_union.

peer_break_target: struct { /// Refers to the enclosing block of the entire switch-on-err expression. block_inst: Zir.Inst.Index, /// Belongs to `block_inst`. block_ri: ResultInfo, }

eu catch |err| label: switch (err) { ... } if (eu) |payload| { ... } else |err| label: switch (err) { ... }

switch must be labeled. Emits a condbr on the non-error body and a regular switch, though the non-error prong and all breaks from switch prongs are peers. Exists to avoid a rather complex special case of switch_block_err_union.

File

zig/AstGen.zig:6994
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
const SwitchNonErr = union(enum) {
    /// A regular switch expression.
    /// Emits `switch_block[_ref]`.
    none,
    /// `eu catch |err| switch (err) { ... }`
    ///
    /// `switch` must not be labeled.
    /// Emits `switch_block_err_union`.
    @"catch",
    /// `if (eu) |payload| { ... } else |err| switch (err) { ... }`
    ///
    /// `switch` must not be labeled.
    /// Emits `switch_block_err_union`.
    @"if": Ast.full.If,
    /// `eu catch |err| label: switch (err) { ... }`
    /// `if (eu) |payload| { ... } else |err| label: switch (err) { ... }`
    ///
    /// `switch` must be labeled.
    /// Emits a `condbr` on the non-error body and a regular switch, though the
    /// non-error prong and all `break`s from switch prongs are peers.
    /// Exists to avoid a rather complex special case of `switch_block_err_union`.
    peer_break_target: struct {
        /// Refers to the enclosing block of the entire switch-on-err expression.
        block_inst: Zir.Inst.Index,
        /// Belongs to `block_inst`.
        block_ri: ResultInfo,
    },
}