Skip to main content

exit

Function exit 

Source
pub unsafe fn exit(status: i32) -> !
Expand description

End the running coroutine at once with status, as if its entry had returned it.

The frames between this call and the entry are abandoned: no destructor runs and nothing unwinds, like a longjmp that never returns. The driver then observes status, and the stack and control block are released as for a normal return. Panics outside a coroutine.

§Safety

Every object that owns a resource (an allocation, an open file, a lock guard) and is live in an abandoned frame is leaked. The caller must have released or must not need such resources, including the entry closure’s own captures: move owned data out of the coroutine stack, or free it before calling. Frames that borrowed data from the caller’s executor side stay valid, as the stack is only dropped by the driver after this call.