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 › Progress › Node › init Private Function init Doc Source Private Function std.Progress.Node.init
fn init (free_index : Index , parent : Parent , name : []const u8 , estimated_total_items : usize ) Node Params free_index : Index parent : Parent name : []const u8 estimated_total_items : usize File Progress.zig: 484
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504 fn init (free_index : Index , parent : Parent , name : []const u8 , estimated_total_items : usize ) Node {
assert (parent == .none or @backingInt (parent ) < node_storage_buffer_len );
const storage = storageByIndex (free_index );
@atomicStore (u32 , &storage .completed_count , 0 , .monotonic );
// Avoid u32 max int which is used to indicate a special state.
const saturated_total_count = @min (std .math .maxInt (u32 ) - 1 , estimated_total_items );
@atomicStore (u32 , &storage .estimated_total_count , saturated_total_count , .monotonic );
const name_len = @min (max_name_len , name .len );
copyAtomicStore (storage .name [0 ..name_len ], name [0 ..name_len ]);
if (name_len < storage .name .len )
@atomicStore (u8 , &storage .name [name_len ], 0 , .monotonic );
const parent_ptr = parentByIndex (free_index );
if (std .debug .runtime_safety ) {
assert (@atomicLoad (Node .Parent , parent_ptr , .monotonic ) == .unused );
}
@atomicStore (Node .Parent , parent_ptr , parent , .monotonic );
return .{ .index = free_index .toOptional () };
}