diff options
| author | Bastian Köcher <git@kchr.de> | 2017-12-23 00:47:25 +0100 |
|---|---|---|
| committer | Bastian Köcher <git@kchr.de> | 2017-12-26 12:26:39 +0100 |
| commit | dbbba553828b1763951fc0eb02fa436ac61d9a95 (patch) | |
| tree | ad72957f2499676126569f300aab23e40fd38c22 /src/libstd | |
| parent | f972f529b2e17e7b6b8ed4a4b4a6ad29917acfce (diff) | |
| download | rust-dbbba553828b1763951fc0eb02fa436ac61d9a95.tar.gz rust-dbbba553828b1763951fc0eb02fa436ac61d9a95.zip | |
Rework the exit failure and success declaration for wasm32
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/termination.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libstd/termination.rs b/src/libstd/termination.rs index cfbeff0de15..61137ba4922 100644 --- a/src/libstd/termination.rs +++ b/src/libstd/termination.rs @@ -9,7 +9,17 @@ // except according to those terms. use error::Error; -use libc; +#[cfg(target_arch = "wasm32")] +mod exit { + pub const SUCCESS: i32 = 0; + pub const FAILURE: i32 = 1; +} +#[cfg(not(target_arch = "wasm32"))] +mod exit { + use libc; + pub const SUCCESS: i32 = libc::EXIT_SUCCESS; + pub const FAILURE: i32 = libc::EXIT_FAILURE; +} /// A trait for implementing arbitrary return types in the `main` function. /// @@ -31,7 +41,7 @@ pub trait Termination { #[unstable(feature = "termination_trait", issue = "43301")] impl Termination for () { - fn report(self) -> i32 { libc::EXIT_SUCCESS } + fn report(self) -> i32 { exit::SUCCESS } } #[unstable(feature = "termination_trait", issue = "43301")] @@ -41,7 +51,7 @@ impl<T: Termination, E: Error> Termination for Result<T, E> { Ok(val) => val.report(), Err(err) => { print_error(err); - libc::EXIT_FAILURE + exit::FAILURE } } } @@ -64,7 +74,7 @@ impl Termination for ! { #[unstable(feature = "termination_trait", issue = "43301")] impl Termination for bool { fn report(self) -> i32 { - if self { libc::EXIT_SUCCESS } else { libc::EXIT_FAILURE } + if self { exit::SUCCESS } else { exit::FAILURE } } } |
