30 lines
589 B
Rust
30 lines
589 B
Rust
pub struct ExitCode(isize);
|
|
|
|
impl ExitCode {
|
|
pub const SUCCESS: ExitCode = ExitCode(0);
|
|
|
|
pub fn to_isize(self) -> isize {
|
|
self.0
|
|
}
|
|
}
|
|
|
|
#[lang = "termination"]
|
|
pub trait Termination {
|
|
/// Is called to get the representation of the value as status code.
|
|
/// This status code is returned to the operating system.
|
|
fn report(self) -> ExitCode;
|
|
}
|
|
|
|
impl Termination for () {
|
|
#[inline]
|
|
fn report(self) -> ExitCode {
|
|
ExitCode::SUCCESS
|
|
}
|
|
}
|
|
impl Termination for isize {
|
|
#[inline]
|
|
fn report(self) -> ExitCode {
|
|
ExitCode(self)
|
|
}
|
|
}
|