summaryrefslogtreecommitdiffstats
path: root/src/util.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-11-13 14:07:15 -0500
committerJesse Luehrs <doy@tozt.net>2021-11-13 14:07:15 -0500
commitf3d3aa2d2ae16d3ec33efed9b5c035ec3d523e0a (patch)
treec8f033e00bf6ba8d66b44cda31f6c01e7da770cf /src/util.rs
parentd8ddced881672115f7dd7b7d5199190d5b80a60f (diff)
downloadnbsh-f3d3aa2d2ae16d3ec33efed9b5c035ec3d523e0a.tar.gz
nbsh-f3d3aa2d2ae16d3ec33efed9b5c035ec3d523e0a.zip
clean up formatting a bit
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs18
1 files changed, 0 insertions, 18 deletions
diff --git a/src/util.rs b/src/util.rs
index 649888c..d792b91 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -3,21 +3,3 @@ pub type Mutex<T> = async_std::sync::Arc<async_std::sync::Mutex<T>>;
pub fn mutex<T>(t: T) -> Mutex<T> {
async_std::sync::Arc::new(async_std::sync::Mutex::new(t))
}
-
-pub fn format_duration(dur: std::time::Duration) -> String {
- let secs = dur.as_secs();
- let nanos = dur.subsec_nanos();
- if secs > 60 {
- let mins = secs / 60;
- let secs = secs - mins * 60;
- format!("{}m{}s", mins, secs)
- } else if secs > 0 {
- format!("{}.{:03}s", secs, nanos / 1_000_000)
- } else if nanos >= 1_000_000 {
- format!("{}ms", nanos / 1_000_000)
- } else if nanos >= 1_000 {
- format!("{}us", nanos / 1_000)
- } else {
- format!("{}ns", nanos)
- }
-}