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 library itself.
pubfnFuture(Result: type) type {
returnstruct {
any_future: ?*AnyFuture,
result: Result,
/// Equivalent to `await` but places a cancelation request. This causes the task to receive/// `error.Canceled` from its next "cancelation point" (if any). A cancelation point is a/// call to a function in `Io` which can return `error.Canceled`.////// After cancelation of a task is requested, only the next cancelation point in that task/// will return `error.Canceled`: future points will not re-signal the cancelation. As such,/// it is usually a bug to ignore `error.Canceled`. However, to defer handling cancelation/// requests, see also `recancel` and `CancelProtection`.////// Idempotent. Not threadsafe.pubfncancel(f: *@This(), io: Io) Result {
constany_future = f.any_futureorelsereturnf.result;
io.vtable.cancel(io.userdata, any_future, @ptrCast(&f.result), .of(Result));
f.any_future = null;
returnf.result;
}
/// Idempotent. Not threadsafe.pubfnawait(f: *@This(), io: Io) Result {
constany_future = f.any_futureorelsereturnf.result;
io.vtable.await(io.userdata, any_future, @ptrCast(&f.result), .of(Result));
f.any_future = null;
returnf.result;
}
};
}