Trait proc_exit::sysexits::ToSysexitsResultExt
source · pub trait ToSysexitsResultExt<T> {
// Required method
fn to_sysexits(self) -> Result<T, Exit>;
}
Expand description
Extension for converting errors to Exit
Example
use proc_exit::prelude::*;
fn main() {
// Simple but Macro-less `main`
// - Fast compiles
// - Composable with other features
let result = run();
proc_exit::exit(result);
}
fn run() -> proc_exit::ExitResult {
// Integrates directly with `std::io::Error`, returning the right exit code.
let exit_status = std::process::Command::new("true")
.status().to_sysexits()?;
// Can pass `Command` exit codes right up, when appropriate
proc_exit::Code::from_status(exit_status).ok()?;
proc_exit::Code::SUCCESS.ok()
}
Required Methods§
sourcefn to_sysexits(self) -> Result<T, Exit>
fn to_sysexits(self) -> Result<T, Exit>
Convert an Error into an Exit