diff options
| author | Fuwn <[email protected]> | 2021-05-17 10:16:42 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-17 10:16:42 +0000 |
| commit | 1b482ab22031ab9a895b2567ba10a2e553752303 (patch) | |
| tree | db4874c46b25655ba7c94b0ab435fdb0d681af55 /src/utils | |
| parent | refactor(global): whirl_config modulized (diff) | |
| download | whirl-1b482ab22031ab9a895b2567ba10a2e553752303.tar.xz whirl-1b482ab22031ab9a895b2567ba10a2e553752303.zip | |
refactor(global): even more modules becoming crates
I did multiple checks and **yes**, everything still works perfectly fine.
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/log.rs | 19 | ||||
| -rw-r--r-- | src/utils/mod.rs | 6 | ||||
| -rw-r--r-- | src/utils/sort.rs | 6 | ||||
| -rw-r--r-- | src/utils/system.rs | 38 |
4 files changed, 0 insertions, 69 deletions
diff --git a/src/utils/log.rs b/src/utils/log.rs deleted file mode 100644 index 39ceca0..0000000 --- a/src/utils/log.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective -// SPDX-License-Identifier: GPL-3.0-only - -use whirl_config::Config; - -pub fn calculate_log_level() -> String { - let mut level; - - level = match Config::get().whirlsplash.log.level { - 2 => "debug".to_string(), - 3 => "trace".to_string(), - _ => "info".to_string(), - }; - if !Config::get().whirlsplash.log.everything { - level = format!("whirl={}", level); - } - - level -} diff --git a/src/utils/mod.rs b/src/utils/mod.rs deleted file mode 100644 index dc9a008..0000000 --- a/src/utils/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective -// SPDX-License-Identifier: GPL-3.0-only - -pub mod log; -pub mod sort; -pub mod system; diff --git a/src/utils/sort.rs b/src/utils/sort.rs deleted file mode 100644 index 131fa55..0000000 --- a/src/utils/sort.rs +++ /dev/null @@ -1,6 +0,0 @@ -// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective -// SPDX-License-Identifier: GPL-3.0-only - -pub fn sort_vec_alphabetically(vec: &mut Vec<&str>) { - vec.sort_by(|a, b| a.to_lowercase().cmp(&b.to_lowercase())); -} diff --git a/src/utils/system.rs b/src/utils/system.rs deleted file mode 100644 index 7a823a0..0000000 --- a/src/utils/system.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective -// SPDX-License-Identifier: GPL-3.0-only - -const WEEK: usize = 60 * 60 * 60 * 60; -const DAY: usize = 60 * 60 * 60; -const HOUR: usize = 60 * 60; -const MIN: usize = 60; - -fn make_parts(t: usize, steps: &[usize], mut accum: Vec<usize>) -> Vec<usize> { - match steps.split_first() { - None => accum, - Some((s, steps)) => { - accum.push(t / *s); - make_parts(t % *s, steps, accum) - } - } -} - -pub fn seconds_to_hrtime(seconds: usize) -> String { - let word = ["week", "day", "hour", "min", "sec"]; - - make_parts(seconds, &[WEEK, DAY, HOUR, MIN, 1], Vec::new()) - .iter() - .enumerate() - .filter_map(|(i, s)| { - if s > &0 { - if s > &1 { - Some(format!("{} {}s", s, word[i])) - } else { - Some(format!("{} {}", s, word[i])) - } - } else { - None - } - }) - .collect::<Vec<String>>() - .join(", ") -} |