Function quit::with_code

source ·
pub fn with_code<T>(exit_code: T) -> !where
    T: Into<ExitCode>,
Expand description

Cleanly exits the program with an exit code.

Calling this function from within an FFI boundary invokes undefined behavior. Because panics are used internally to unwind the stack, the exit code cannot be passed safely. process::exit should be used instead in that case.

This function will not behave as expected unless #[main] is attached to the main function. Other implementation notes are mentioned in the module-level documentation.

Examples

fn exit() -> ! {
    quit::with_code(1);
}