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 › PkgConfig › find Public Function find Doc Source Public Function std.zig.PkgConfig.find
pub fn find (pc : *const PkgConfig , lib_name : []const u8 ) ?usize Params File zig/PkgConfig.zig: 52
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 pub fn find (pc : *const PkgConfig , lib_name : []const u8 ) ?usize {
const all = pc .all ;
// Exact match means instant winner.
for (all , 0 ..) |pkg , i | {
if (mem .eql (u8 , pkg .name , lib_name ))
return i ;
}
// Next we'll try ignoring case.
for (all , 0 ..) |pkg , i | {
if (std .ascii .eqlIgnoreCase (pkg .name , lib_name ))
return i ;
}
// Prefixed "lib" or suffixed ".0".
for (all , 0 ..) |pkg , i | {
if (std .ascii .findIgnoreCase (pkg .name , lib_name )) |pos | {
const prefix = pkg .name [0 ..pos ];
const suffix = pkg .name [pos + lib_name .len ..];
if (prefix .len > 0 and !mem .eql (u8 , prefix , "lib" )) continue ;
if (suffix .len > 0 and !mem .eql (u8 , suffix , ".0" )) continue ;
return i ;
}
}
// Trimming "-1.0".
if (mem .cutSuffix (u8 , lib_name , "-1.0" )) |trimmed | {
for (all , 0 ..) |pkg , i | {
if (std .ascii .eqlIgnoreCase (pkg .name , trimmed )) {
return i ;
}
}
}
return null ;
}