tiny.mprompt.yieldWith
Defined in zig_api.
Suspends the body at prompt and runs handler(continuation, handler_context, value) on the stack of the code that called run, so that a handler outside the body computes its next value, as a generator hands out each value or a worker asks for input.
Source
Source: lib/mprompt/src/api.zig:460
zig
/// Suspends the body at `prompt` and runs `handler(continuation, handler_context, value)` on the/// stack of the code that called `run`, so that a handler outside the body computes its next value,/// as a generator hands out each value or a worker asks for input. The call returns the value the/// handler continues the body with. The handler receives `value` by copy. `handler_context` must be/// a pointer, and any other type is a compile error. The handler must continue the body before it/// returns, and a handler that returns without continuing stops the program with a panic. `prompt`/// must be the prompt the body received from `run`, and the body must still be running on it, which/// assertions check in safe builds. `PromptResult` must be the `Result` type of the enclosing/// `run`.pub fn yieldWith( comptime ResumeValue: type, comptime PromptResult: type, prompt: *Prompt, value: anytype, handler_context: anytype, comptime handler: *const fn (Continuation(ResumeValue, PromptResult), @TypeOf(handler_context), @TypeOf(value)) void,) ResumeValue { const YieldValue = @TypeOf(value); const HandlerContext = @TypeOf(handler_context); requirePointer(HandlerContext, "yieldWith handler context"); const Environment: type = YieldWithEnvironmentType( ResumeValue, PromptResult, YieldValue, HandlerContext, handler, ); var environment: Environment = .{ .value = value, .handler_context = handler_context, }; return readSlot(ResumeValue, raw.yieldPrompt(prompt, Environment.onYield, &environment));}Source: lib/mprompt/src/root.zig:67
zig
pub const yieldWith = zig_api.yieldWith;Audit
| Definitions | 1 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |