Skip to documentation
SLOP

tiny.mprompt.yieldWith

Reference 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.

Called byCallsprivate sourcelib.mprompt.src.apiaddAfterSuspendprivate sourcelib.mprompt.src.apiproduceValueszig_apiContinuationprivate sourcelib.mprompt.src.apiYieldWithEnvironmentTypeprivate sourcelib.mprompt.src.apireadSlotprivate sourcelib.mprompt.src.apirequirePointerzig_apiyieldWith
Static calls · unresolved targets: 1 · external targets: 1.

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

Definitions1
Public names2
Members0
Version26.7.0
Revisiondaab053ee433