Skip to content

Commit

Permalink
Rollup merge of rust-lang#95058 - wcampbell0x2a:use-then-in-unix-proc…
Browse files Browse the repository at this point in the history
…ess, r=dtolnay

Add use of bool::then in sys/unix/process

Remove `else { None }` in favor of using `bool::then()`
  • Loading branch information
matthiaskrgr authored Mar 18, 2022
2 parents 4ead6d9 + b1f3179 commit c8cf9e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/std/src/sys/unix/process/process_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,19 +648,19 @@ impl ExitStatus {
}

pub fn code(&self) -> Option<i32> {
if self.exited() { Some(libc::WEXITSTATUS(self.0)) } else { None }
self.exited().then(|| libc::WEXITSTATUS(self.0))
}

pub fn signal(&self) -> Option<i32> {
if libc::WIFSIGNALED(self.0) { Some(libc::WTERMSIG(self.0)) } else { None }
libc::WIFSIGNALED(self.0).then(|| libc::WTERMSIG(self.0))
}

pub fn core_dumped(&self) -> bool {
libc::WIFSIGNALED(self.0) && libc::WCOREDUMP(self.0)
}

pub fn stopped_signal(&self) -> Option<i32> {
if libc::WIFSTOPPED(self.0) { Some(libc::WSTOPSIG(self.0)) } else { None }
libc::WIFSTOPPED(self.0).then(|| libc::WSTOPSIG(self.0))
}

pub fn continued(&self) -> bool {
Expand Down

0 comments on commit c8cf9e3

Please sign in to comment.