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 › AstGen › negation Private Function negation Doc Source 9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860 fn negation (
gz : *GenZir ,
scope : *Scope ,
ri : ResultInfo ,
node : Ast .Node .Index ,
) InnerError !Zir .Inst .Ref {
const astgen = gz .astgen ;
const tree = astgen .tree ;
// Check for float literal as the sub-expression because we want to preserve
// its negativity rather than having it go through comptime subtraction.
const operand_node = tree .nodeData (node ).node ;
if (tree .nodeTag (operand_node ) == .number_literal ) {
return numberLiteral (gz , ri , operand_node , node , .negative );
}
const operand = try expr (gz , scope , .{ .rl = .none }, operand_node );
const result = try gz .addUnNode (.negate , operand , node );
return rvalue (gz , ri , result , node );
}