tiny.mprompt.run
Defined in zig_api.
A caller runs the body to its end in one call, and a handler answers each pause before the body goes on.
Source
Source: lib/mprompt/src/api.zig:391
zig
/// A caller runs the body to its end in one call, and a handler answers each pause before the body/// goes on. The call creates a prompt with a new stacklet, runs `body(prompt, context)` on it, and/// returns what the body returns. The prompt marks where the body entered its stacklet, and the/// body passes it to `yieldWith` to pause back to that point. `context` must be a pointer, and any/// other type is a compile error. An error union passes through: a body that returns an error makes/// `run` return that error. The stacklet comes from the calling thread's cache or from a new/// reservation. The first prompt in a process initializes the runtime with the default/// configuration when `init` has not run. The runtime releases the stacklet when the body returns./// The body pauses with `yieldWith`. `suspendPrompt` is only for bodies started by `SuspendedRun`.pub fn run( comptime Result: type, context: anytype, comptime body: *const fn (*Prompt, @TypeOf(context)) Result,) Result { const Context = @TypeOf(context); requirePointer(Context, "run context"); const Environment: type = RunEnvironmentType(Result, Context, body); var environment: Environment = .{ .context = context }; return readSlot(Result, raw.prompt(Environment.start, &environment));}Source: lib/mprompt/src/root.zig:64
zig
pub const run = zig_api.run;Audit
| Definitions | 1 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |