Zig 0.17.0-dev (Split by item) 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.
std › zig › Zir › UnwrappedSwitchBlock › Case › Iterator Public Struct Iterator Doc Source Public Struct std.zig.Zir.UnwrappedSwitchBlock.Case.Iterator
pub const Iterator = struct Fields Functions File zig/Zir.zig: 5164
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201 pub const Iterator = struct {
next_idx : u32 ,
prong_infos : []const Inst .SwitchBlock .ProngInfo ,
multi_case_items_lens : []const u32 ,
multi_case_ranges_lens : ?[]const u32 ,
item_infos : []const Inst .SwitchBlock .ItemInfo ,
pub fn next (it : *Iterator ) ?Case {
const idx = it .next_idx ;
if (idx == it .prong_infos .len ) return null ;
it .next_idx += 1 ;
const scalar_cases_len = it .prong_infos .len - it .multi_case_items_lens .len ;
return if (idx < scalar_cases_len ) .{
.index = .{
.kind = .scalar ,
.value = @intCast (idx ),
},
.prong_info = it .prong_infos [idx ],
.item_infos = it .itemInfos (1 ),
.range_infos = &.{},
} else .{
.index = .{
.kind = .multi ,
.value = @intCast (idx - scalar_cases_len ),
},
.prong_info = it .prong_infos [idx ],
.item_infos = it .itemInfos (it .multi_case_items_lens [idx - scalar_cases_len ]),
.range_infos = if (it .multi_case_ranges_lens ) |ranges_lens | b : {
break :b @ptrCast (it .itemInfos (2 * ranges_lens [idx - scalar_cases_len ]));
} else &.{},
};
}
fn itemInfos (it : *Iterator , count : u32 ) []const Inst .SwitchBlock .ItemInfo {
const lens = it .item_infos [0 ..count ];
it .item_infos = it .item_infos [count ..];
return lens ;
}
}