]> git.lizzy.rs Git - rust.git/commit
unix: impl ExitStatusExt for ExitStatusError
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 24 Feb 2021 14:52:16 +0000 (14:52 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 12 May 2021 10:12:19 +0000 (11:12 +0100)
commit60a4d9612d5cd5dde600bbf7a3cb5431f55de670
treeb0b7f78a61a3a29ac2925517d0e9fee9a4e12295
parente893089ea066ce2b339543ac8e59b4e0ca8c44d3
unix: impl ExitStatusExt for ExitStatusError

It is unergnomic to have to say things like
   bad.into_status().signal()

Implementing `ExitStatusExt` for `ExitStatusError` fixes this.
Unfortunately it does mean making a previously-infallible method
capable of panicing, although of course the existing impl remains
infallible.

The alternative would be a whole new `ExitStatusErrorExt` trait.

`<ExitStatus as ExitStatusExt>::into_raw()` is not particularly
ergonomic to call because of the often-required type annotation.
See for example the code in the test case in
  library/std/src/sys/unix/process/process_unix/tests.rs

Perhaps we should provide equivalent free functions for `ExitStatus`
and `ExitStatusExt` in std::os::unix::process and maybe deprecate this
trait method.  But I think that is for the future.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
library/std/src/os/unix/process.rs
library/std/src/process.rs