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 › os › windows › STRING Private Type Function STRING Doc Source Private Type Function std.os.windows.STRING
fn STRING (comptime C : type ) type Fields Values Functions pub fn init (string : []const C ) @This () pub fn initZ (string : [: 0 ]const C ) @This () pub fn isEmpty (string : *const @This ()) bool pub fn slice (string : *const @This ()) []C pub fn sliceZ (string : *const @This ()) [: 0 ]C File os/windows.zig: 4043
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082 fn STRING (comptime C : type ) type {
return extern struct {
Length : USHORT ,
MaximumLength : USHORT ,
Buffer : ?[*]C ,
pub const empty : @This () = .{ .Length = 0 , .MaximumLength = 0 , .Buffer = null };
pub fn init (string : []const C ) @This () {
const len : USHORT = @intCast (@sizeOf (C ) * string .len );
return .{
.Length = len ,
.MaximumLength = len ,
.Buffer = @constCast (string .ptr ),
};
}
pub fn initZ (string : [:0 ]const C ) @This () {
const len : USHORT = @intCast (@sizeOf (C ) * string .len );
return .{
.Length = len ,
.MaximumLength = len + @sizeOf (C ),
.Buffer = @constCast (string .ptr ),
};
}
pub fn isEmpty (string : *const @This ()) bool {
return string .Length == 0 ;
}
pub fn slice (string : *const @This ()) []C {
return if (string .isEmpty ()) &.{} else string .Buffer .?[0 ..@divExact (string .Length , @sizeOf (C ))];
}
pub fn sliceZ (string : *const @This ()) [:0 ]C {
assert (string .Length + @sizeOf (C ) <= string .MaximumLength );
return string .Buffer .?[0 ..@divExact (string .Length , @sizeOf (C )) :0 ];
}
};
}