fix formatting, fixing users!!

This commit is contained in:
Reid 2023-08-31 14:55:34 -07:00
parent 793a8dcb7a
commit 847d8ea35c
Signed by: reidlab
GPG key ID: 6C9EAA3364F962C8
2 changed files with 8 additions and 5 deletions

View file

@ -34,5 +34,4 @@ _these features are implemented_
## todo ## 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] - move authorization logic to (./src/helpers/accounts.rs)[./src/helpers/accounts.rs]

View file

@ -1,14 +1,18 @@
use std::collections::HashMap; use std::collections::HashMap;
pub fn format(map: HashMap<i32, impl ToString>) -> String { pub fn format(map: HashMap<i32, impl ToString>) -> String {
let mut sorted_keys: Vec<i32> = map.keys().copied().collect();
sorted_keys.sort();
let mut result = String::new(); let mut result = String::new();
for (k, v) in map { for key in sorted_keys {
result.push_str(&format!("{}:{}", k, v.to_string())); if let Some(val) = map.get(&key) {
result.push(':'); result.push_str(&format!("{}:{}:", key, val.to_string()));
}
} }
if !result.is_empty() { if !result.ends_with(":") {
result.pop(); result.pop();
} }