diff options
| author | bors <bors@rust-lang.org> | 2024-09-16 22:55:33 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-16 22:55:33 +0000 | 
| commit | bde6bf2b07b61f7da92c211d2b4a897ea4620e1b (patch) | |
| tree | 02b9eea003573f6b0d9e0aaaa1d81bef4c0da75c /library/std/src/process.rs | |
| parent | c52c23b6f44cd19718721a5e3b2eeb169e9c96ff (diff) | |
| parent | 2f0eb5f44d79ae5a40cf6c7ec1dff5659eda9405 (diff) | |
| download | rust-bde6bf2b07b61f7da92c211d2b4a897ea4620e1b.tar.gz rust-bde6bf2b07b61f7da92c211d2b4a897ea4620e1b.zip | |
Auto merge of #127633 - SamuelMarks:eq-exit-code, r=dtolnay
[library/std/src/process.rs] `PartialEq` for `ExitCode` Converting a third-party CLI to a library so started passing around [`std::process::ExitCode`](https://doc.rust-lang.org/std/process/struct.ExitCode.html) in an `Either`. Then I realised the tests can't be modified to compare equality of `ExitCode`s. This PR fixes this oversight.
Diffstat (limited to 'library/std/src/process.rs')
| -rw-r--r-- | library/std/src/process.rs | 14 | 
1 files changed, 9 insertions, 5 deletions
| diff --git a/library/std/src/process.rs b/library/std/src/process.rs index a155855029e..60d452465da 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -1910,10 +1910,14 @@ impl crate::error::Error for ExitStatusError {} /// to its parent under normal termination. /// /// `ExitCode` is intended to be consumed only by the standard library (via -/// [`Termination::report()`]), and intentionally does not provide accessors like -/// `PartialEq`, `Eq`, or `Hash`. Instead the standard library provides the -/// canonical `SUCCESS` and `FAILURE` exit codes as well as `From<u8> for -/// ExitCode` for constructing other arbitrary exit codes. +/// [`Termination::report()`]). For forwards compatibility with potentially +/// unusual targets, this type currently does not provide `Eq`, `Hash`, or +/// access to the raw value. This type does provide `PartialEq` for +/// comparison, but note that there may potentially be multiple failure +/// codes, some of which will _not_ compare equal to `ExitCode::FAILURE`. +/// The standard library provides the canonical `SUCCESS` and `FAILURE` +/// exit codes as well as `From<u8> for ExitCode` for constructing other +/// arbitrary exit codes. /// /// # Portability /// @@ -1952,7 +1956,7 @@ impl crate::error::Error for ExitStatusError {} /// ExitCode::SUCCESS /// } /// ``` -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, PartialEq)] #[stable(feature = "process_exitcode", since = "1.61.0")] pub struct ExitCode(imp::ExitCode); | 
