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 › UnwrappedStructDecl › FieldIterator Public Struct FieldIterator Doc Source Public Struct std.zig.Zir.UnwrappedStructDecl.FieldIterator
pub const FieldIterator = struct Fields next_idx : u32 names : []const NullTerminatedString type_body_lens : []const u32 align_body_lens : ?[]const u32 default_body_lens : ?[]const u32 comptime_bits : ?[]const u32 bodies_overlong : []const Inst .Index Structs Functions File zig/Zir.zig: 5378
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418 pub const FieldIterator = struct {
next_idx : u32 ,
names : []const NullTerminatedString ,
type_body_lens : []const u32 ,
align_body_lens : ?[]const u32 ,
default_body_lens : ?[]const u32 ,
comptime_bits : ?[]const u32 ,
bodies_overlong : []const Inst .Index ,
pub const Field = struct {
idx : u32 ,
name : NullTerminatedString ,
type_body : []const Inst .Index ,
align_body : ?[]const Inst .Index ,
default_body : ?[]const Inst .Index ,
is_comptime : bool ,
};
pub fn next (it : *FieldIterator ) ?Field {
const idx = it .next_idx ;
if (idx == it .names .len ) return null ;
it .next_idx += 1 ;
return .{
.idx = idx ,
.name = it .names [idx ],
.type_body = it .body (it .type_body_lens [idx ]).?,
.align_body = it .body (if (it .align_body_lens ) |l | l [idx ] else 0 ),
.default_body = it .body (if (it .default_body_lens ) |l | l [idx ] else 0 ),
.is_comptime = ct : {
const bits = it .comptime_bits orelse break :ct false ;
const big = bits [idx / 32 ];
const shifted = big >> @intCast (idx % 32 );
break :ct @as (u1 , @truncate (shifted )) == 1 ;
},
};
}
fn body (it : *FieldIterator , len : u32 ) ?[]const Inst .Index {
if (len == 0 ) return null ;
const b = it .bodies_overlong [0 ..len ];
it .bodies_overlong = it .bodies_overlong [len ..];
return b ;
}
}