From 80c884f48983104fcfd87566454d1bc042b0f518 Mon Sep 17 00:00:00 2001 From: reidlab Date: Tue, 29 Aug 2023 01:10:33 -0700 Subject: [PATCH] add some formatting shit --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/helpers.rs | 1 + src/helpers/format.rs | 16 ++++++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 src/helpers/format.rs diff --git a/Cargo.lock b/Cargo.lock index a3d0865..aa19066 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -408,6 +408,7 @@ version = "0.0.0" dependencies = [ "diesel", "dotenvy", + "maplit", "password-auth", "regex", "rocket", @@ -655,6 +656,12 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "matchers" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 7ca0d8b..7b492b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" [dependencies] diesel = { version = "=2.1.0", features = ["postgres"] } dotenvy = "0.15.7" +maplit = "1.0.2" password-auth = "0.3.0" regex = "1.9.4" rocket = "=0.5.0-rc.3" diff --git a/src/helpers.rs b/src/helpers.rs index 96f8dc1..d4d9ee6 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,3 +1,4 @@ pub mod accounts; pub mod clean; +pub mod format; pub mod gjp2; \ No newline at end of file diff --git a/src/helpers/format.rs b/src/helpers/format.rs new file mode 100644 index 0000000..593fcf7 --- /dev/null +++ b/src/helpers/format.rs @@ -0,0 +1,16 @@ +use std::collections::HashMap; + +pub fn format(map: HashMap) -> String { + let mut result = String::new(); + + for (k, v) in map { + result.push_str(&format!("{}:{}", k, v.to_string())); + result.push(':'); + } + + if !result.is_empty() { + result.pop(); + } + + return result; +} \ No newline at end of file