summaryrefslogtreecommitdiffstats
path: root/src/format.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/format.rs')
-rw-r--r--src/format.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/format.rs b/src/format.rs
index e552f53..e88f5a9 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -37,3 +37,12 @@ pub fn duration(dur: std::time::Duration) -> String {
format!("{}ns", nanos)
}
}
+
+pub fn io_error(e: &std::io::Error) -> String {
+ let mut s = format!("{}", e);
+ if e.raw_os_error().is_some() {
+ let i = s.rfind('(').unwrap();
+ s.truncate(i - 1);
+ }
+ s
+}