Skip to content

Commit 2819604

Browse files
committed
Auto merge of rust-lang#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.
2 parents 9af97fc + b2d6fdd commit 2819604

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

std/src/process.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1910,10 +1910,14 @@ impl crate::error::Error for ExitStatusError {}
19101910
/// to its parent under normal termination.
19111911
///
19121912
/// `ExitCode` is intended to be consumed only by the standard library (via
1913-
/// [`Termination::report()`]), and intentionally does not provide accessors like
1914-
/// `PartialEq`, `Eq`, or `Hash`. Instead the standard library provides the
1915-
/// canonical `SUCCESS` and `FAILURE` exit codes as well as `From<u8> for
1916-
/// ExitCode` for constructing other arbitrary exit codes.
1913+
/// [`Termination::report()`]). For forwards compatibility with potentially
1914+
/// unusual targets, this type currently does not provide `Eq`, `Hash`, or
1915+
/// access to the raw value. This type does provide `PartialEq` for
1916+
/// comparison, but note that there may potentially be multiple failure
1917+
/// codes, some of which will _not_ compare equal to `ExitCode::FAILURE`.
1918+
/// The standard library provides the canonical `SUCCESS` and `FAILURE`
1919+
/// exit codes as well as `From<u8> for ExitCode` for constructing other
1920+
/// arbitrary exit codes.
19171921
///
19181922
/// # Portability
19191923
///
@@ -1952,7 +1956,7 @@ impl crate::error::Error for ExitStatusError {}
19521956
/// ExitCode::SUCCESS
19531957
/// }
19541958
/// ```
1955-
#[derive(Clone, Copy, Debug)]
1959+
#[derive(Clone, Copy, Debug, PartialEq)]
19561960
#[stable(feature = "process_exitcode", since = "1.61.0")]
19571961
pub struct ExitCode(imp::ExitCode);
19581962

0 commit comments

Comments
 (0)