Skip to content

Commit

Permalink
Auto merge of rust-lang#114589 - ijackson:exit-code-default, r=dtolnay
Browse files Browse the repository at this point in the history
impl Default for ExitCode

As suggested here
  rust-lang#106425 (comment)

Needs FCP since this is an insta-stable impl.

Ideally we would have `impl From<ExitCode> for ExitStatus` and implement the default `ExitStatus` using that.   That is sadly not so easy because of the various strange confusions about `ExitCode` (unix: exit status) vs `ExitStatus` (unix: wait status) in the not-really-unix platforms in `library//src/sys/unix/process`.  I'll try to follow that up.
  • Loading branch information
bors committed Oct 16, 2023
2 parents 30d310c + b149d16 commit 58352c0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ impl From<io::Stderr> for Stdio {
pub struct ExitStatus(imp::ExitStatus);

/// The default value is one which indicates successful completion.
#[stable(feature = "process-exitcode-default", since = "1.73.0")]
#[stable(feature = "process_exitstatus_default", since = "1.73.0")]
impl Default for ExitStatus {
fn default() -> Self {
// Ideally this would be done by ExitCode::default().into() but that is complicated.
Expand Down Expand Up @@ -1960,6 +1960,14 @@ impl ExitCode {
}
}

/// The default value is [`ExitCode::SUCCESS`]
#[stable(feature = "process_exitcode_default", since = "CURRENT_RUSTC_VERSION")]
impl Default for ExitCode {
fn default() -> Self {
ExitCode::SUCCESS
}
}

#[stable(feature = "process_exitcode", since = "1.61.0")]
impl From<u8> for ExitCode {
/// Construct an `ExitCode` from an arbitrary u8 value.
Expand Down

0 comments on commit 58352c0

Please sign in to comment.