summaryrefslogtreecommitdiffstats
path: root/src/format.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-10 04:50:42 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-10 04:50:42 -0500
commit75774fa13f9dbd02838a3e0984bd4d0dfbaca9d8 (patch)
tree0d7c906890de1987bb1412424c201766f05c84d5 /src/format.rs
parent8647c6ec2767c06b9612284dbf22bea0ee944f47 (diff)
downloadnbsh-75774fa13f9dbd02838a3e0984bd4d0dfbaca9d8.tar.gz
nbsh-75774fa13f9dbd02838a3e0984bd4d0dfbaca9d8.zip
clippy
Diffstat (limited to 'src/format.rs')
-rw-r--r--src/format.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/format.rs b/src/format.rs
index 9086500..e552f53 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -1,15 +1,15 @@
use std::os::unix::process::ExitStatusExt as _;
pub fn exit_status(status: std::process::ExitStatus) -> String {
- if let Some(sig) = status.signal() {
- if let Some(name) = signal_hook::low_level::signal_name(sig) {
- format!("{:4} ", &name[3..])
- } else {
- format!("SIG{} ", sig)
- }
- } else {
- format!("{:03} ", status.code().unwrap())
- }
+ status.signal().map_or_else(
+ || format!("{:03} ", status.code().unwrap()),
+ |sig| {
+ signal_hook::low_level::signal_name(sig).map_or_else(
+ || format!("SIG{} ", sig),
+ |name| format!("{:4} ", &name[3..]),
+ )
+ },
+ )
}
pub fn time(time: time::OffsetDateTime) -> String {