diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-09-19 20:37:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-19 20:37:08 +0200 |
| commit | 553c20cc9262ec9ad5c068d12fc21947991bbb4e (patch) | |
| tree | 3ca50551ca49c5ceba8f1eb99457af6178891121 /library/std/src | |
| parent | 569153a432775da4be886c0163030234880fc656 (diff) | |
| parent | dc628c8ecb8d24f88850894e01e7bd027cc9af61 (diff) | |
| download | rust-553c20cc9262ec9ad5c068d12fc21947991bbb4e.tar.gz rust-553c20cc9262ec9ad5c068d12fc21947991bbb4e.zip | |
Rollup merge of #130554 - ShE3py:unsupported-exitcode, r=Noratrieb
`pal::unsupported::process::ExitCode`: use an `u8` instead of a `bool` `ExitCode` should “represents the status code the current process can return to its parent under normal termination”, but is currently represented as a `bool` on unsupported platforms, making the `impl From<u8> for ExitCode` lossy. Fixes #130532. History: [IRLO thread](https://internals.rust-lang.org/t/mini-pre-rfc-redesigning-process-exitstatus/5426) (`ExitCode` as a `main` return), #48618 (initial impl), #93445 (`From<u8>` impl).
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/pal/unsupported/process.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/library/std/src/sys/pal/unsupported/process.rs b/library/std/src/sys/pal/unsupported/process.rs index 40231bfc90b..fee81744f09 100644 --- a/library/std/src/sys/pal/unsupported/process.rs +++ b/library/std/src/sys/pal/unsupported/process.rs @@ -255,11 +255,11 @@ impl ExitStatusError { } #[derive(PartialEq, Eq, Clone, Copy, Debug)] -pub struct ExitCode(bool); +pub struct ExitCode(u8); impl ExitCode { - pub const SUCCESS: ExitCode = ExitCode(false); - pub const FAILURE: ExitCode = ExitCode(true); + pub const SUCCESS: ExitCode = ExitCode(0); + pub const FAILURE: ExitCode = ExitCode(1); pub fn as_i32(&self) -> i32 { self.0 as i32 @@ -268,10 +268,7 @@ impl ExitCode { impl From<u8> for ExitCode { fn from(code: u8) -> Self { - match code { - 0 => Self::SUCCESS, - 1..=255 => Self::FAILURE, - } + Self(code) } } |
