about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-03-18 21:50:49 +0100
committerGitHub <noreply@github.com>2022-03-18 21:50:49 +0100
commitc8cf9e3a8fa5a8296bf1506dbbe2eb4b098f471f (patch)
treecd5e7bda8f31e13d86ef5c966aca404be78af88f /library/std/src
parent4ead6d9dc7d32c0c54adb444e529b772bce6370c (diff)
parentb1f31798045ccb5933749e01cc08ce6621889764 (diff)
downloadrust-c8cf9e3a8fa5a8296bf1506dbbe2eb4b098f471f.tar.gz
rust-c8cf9e3a8fa5a8296bf1506dbbe2eb4b098f471f.zip
Rollup merge of #95058 - wcampbell0x2a:use-then-in-unix-process, r=dtolnay
Add use of bool::then in sys/unix/process

Remove `else { None }` in favor of using `bool::then()`
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/unix/process/process_unix.rs6
1 files changed, 3 insertions, 3 deletions
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 @@ 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 {
@@ -660,7 +660,7 @@ impl ExitStatus {
     }
 
     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 {