From 847d8ea35c56c7eb1b346fb8a1100a11f3416d9e Mon Sep 17 00:00:00 2001 From: reidlab Date: Thu, 31 Aug 2023 14:55:34 -0700 Subject: [PATCH] fix formatting, fixing users!! --- readme.md | 1 - src/helpers/format.rs | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index e594f53..35c1143 100644 --- a/readme.md +++ b/readme.md @@ -34,5 +34,4 @@ _these features are implemented_ ## todo -- fix gd not parsing the response from get_users correctly (sometimes has a hashtag in it? sometimes not? idfk) - move authorization logic to (./src/helpers/accounts.rs)[./src/helpers/accounts.rs] \ No newline at end of file diff --git a/src/helpers/format.rs b/src/helpers/format.rs index 593fcf7..beaf5ae 100644 --- a/src/helpers/format.rs +++ b/src/helpers/format.rs @@ -1,14 +1,18 @@ use std::collections::HashMap; pub fn format(map: HashMap) -> String { + let mut sorted_keys: Vec = map.keys().copied().collect(); + sorted_keys.sort(); + let mut result = String::new(); - for (k, v) in map { - result.push_str(&format!("{}:{}", k, v.to_string())); - result.push(':'); + for key in sorted_keys { + if let Some(val) = map.get(&key) { + result.push_str(&format!("{}:{}:", key, val.to_string())); + } } - if !result.is_empty() { + if !result.ends_with(":") { result.pop(); }