Skip to content

Commit c8cf9e3

Browse files
authored
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()`
2 parents 4ead6d9 + b1f3179 commit c8cf9e3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/std/src/sys/unix/process/process_unix.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -648,19 +648,19 @@ impl ExitStatus {
648648
}
649649

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

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

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

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

666666
pub fn continued(&self) -> bool {

0 commit comments

Comments
 (0)