diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 9c477e5addc..9d2803b40c4 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -648,11 +648,11 @@ pub fn exit_ok(&self) -> Result<(), ExitStatusError> { } pub fn code(&self) -> Option { - if self.exited() { Some(libc::WEXITSTATUS(self.0)) } else { None } + self.exited().then(|| libc::WEXITSTATUS(self.0)) } pub fn signal(&self) -> Option { - 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 { @@ -660,7 +660,7 @@ pub fn core_dumped(&self) -> bool { } pub fn stopped_signal(&self) -> Option { - 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 {