zigar.function.GeneratorOf(function) - chung-leong/zigar GitHub Wiki

Define a generator type with the return value type of function as the payload

Example:

const std = @import("std");
const zigar = @import("zigar");

fn hello() error{InitFailed}!Iterator {
    return error.InitFailed;
}

const Iterator = struct {
    pub fn next(_: *@This()) error{NextFailed}!?i32 {
        return null;
    }
};

comptime {
    std.debug.assert(zigar.function.GeneratorOf(hello) == zigar.function.Generator(error{ InitFailed, NextFailed }!?i32));
}

Arguments:

  • function: anytype
    A function or a function type.

Return value:

Generator(T)


Generator(T) | GeneratorArgOf(function)