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 › Io › Dispatch › Fiber › CancelProtection Private Struct CancelProtection Doc Source Private Struct std.Io.Dispatch.Fiber.CancelProtection
const CancelProtection = packed struct Fields user : Io .CancelProtection acknowledged : bool Values Functions File Io/Dispatch.zig: 153
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188 const CancelProtection = packed struct {
user : Io .CancelProtection ,
acknowledged : bool ,
const unblocked : CancelProtection = .{ .user = .unblocked , .acknowledged = false };
fn check (cancel_protection : CancelProtection ) Io .CancelProtection {
return @fromBackingInt (@intCast (@intFromBool (cancel_protection != unblocked )));
}
fn acknowledge (cancel_protection : *CancelProtection ) void {
assert (!cancel_protection .acknowledged );
cancel_protection .acknowledged = true ;
}
fn recancel (cancel_protection : *CancelProtection ) void {
assert (cancel_protection .acknowledged );
cancel_protection .acknowledged = false ;
}
test check {
try std .testing .expectEqual (Io .CancelProtection .unblocked , check (.unblocked ));
try std .testing .expectEqual (Io .CancelProtection .blocked , check (.{
.user = .unblocked ,
.acknowledged = true ,
}));
try std .testing .expectEqual (Io .CancelProtection .blocked , check (.{
.user = .blocked ,
.acknowledged = false ,
}));
try std .testing .expectEqual (Io .CancelProtection .blocked , check (.{
.user = .blocked ,
.acknowledged = true ,
}));
}
}