zigar.function.Generator(T, allocating) - chung-leong/zigar GitHub Wiki
Define a generator type that will act as an interface to a JavaScript
async generator object. When yield()
is called with a value, the generate returns a
value on the JavaScript side. When the function is given an error instead, then the
generator throws.
Arguments:
T
:type
Payload type. Must be anoptional
type.allocating
:bool
Whether an allocator should be attached to the generator.
Struct fields:
allocator
:std.mem.Allocator
Source of memory for generated items. Each timeyield()
is called, previously allocated memory get released. It's present only ifallocating
is true.ptr
:?*anyopaque
Optional opaque pointer that gets passed tocallback
. Default tonull
.callback
*const fn (?*anyopaque, T) void
Pointer to callback function that's called byyield()
.
Constants:
payload
=T
Functions: