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 › sort › block › swap Private Function swap Doc Source Private Function std.sort.block.swap
fn swap (
comptime T : type ,
items : []T ,
order : *[8 ]u8 ,
x : usize ,
y : usize ,
context : anytype ,
comptime lessThan : fn (@TypeOf (context ), lhs : T , rhs : T ) bool ,
) void Params T : type items : []T order : *[8 ]u8 x : usize y : usize context lessThan : fn (@TypeOf (context ), lhs : T , rhs : T ) bool File sort/block.zig: 1062
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075 fn swap (
comptime T : type ,
items : []T ,
order : *[8 ]u8 ,
x : usize ,
y : usize ,
context : anytype ,
comptime lessThan : fn (@TypeOf (context ), lhs : T , rhs : T ) bool ,
) void {
if (lessThan (context , items [y ], items [x ]) or ((order .*)[x ] > (order .*)[y ] and !lessThan (context , items [x ], items [y ]))) {
mem .swap (T , &items [x ], &items [y ]);
mem .swap (u8 , &(order .*)[x ], &(order .*)[y ]);
}
}