pub enum SuspendKind {
Initial,
Yield,
YieldStar,
AsyncYieldStar,
Await,
}Expand description
Why a frame parked, which decides how the resumption is delivered.
Variants§
Initial
initial_yield: the body has not started. The first next() resumes after it
without passing a value, because there is no yield expression to receive one.
Yield
yield expr: the value is on the stack and the caller gets {value, done:false}.
YieldStar
yield* expr in a sync generator: like Yield, but the value is already an
{value, done} object from the inner iterator and is handed straight back.
AsyncYieldStar
yield* expr in an async generator: the compiled shape extracts .value first, so
what was yielded is the plain value and still has to be awaited and wrapped —
AsyncGeneratorYield does Await(value) before handing it out. Sharing YieldStar
made it pass a bare value through as if it were an iterator result, so
async function* g(){ yield* [1] } answered {value: {value: 1, done: false}}.
Await
await expr: the value is a promise the async machinery has to settle first.