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 › zon › parse › Parser › parseInt Private Function parseInt Doc Source Private Function std.zon.parse.Parser.parseInt
fn parseInt (self : @This (), T : type , node : Zoir .Node .Index ) !T Params self : @This () T : type node : Zoir .Node .Index File zon/parse.zig: 635
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650 fn parseInt (self : @This (), T : type , node : Zoir .Node .Index ) !T {
switch (node .get (self .zoir )) {
.int_literal => |int | switch (int ) {
.small => |val | return std .math .cast (T , val ) orelse
self .failCannotRepresent (T , node ),
.big => |val | return val .toInt (T ) catch
self .failCannotRepresent (T , node ),
},
.float_literal => |val | return intFromFloatExact (T , val ) orelse
self .failCannotRepresent (T , node ),
.char_literal => |val | return std .math .cast (T , val ) orelse
self .failCannotRepresent (T , node ),
else => return error .WrongType ,
}
}