From b88c583b34a8e0c3448c17d087a9337ecf724a66 Mon Sep 17 00:00:00 2001 From: Nat <126206823+thenatx@users.noreply.github.com> Date: Mon, 18 Nov 2024 01:22:09 +0000 Subject: [PATCH 1/4] chore: Delete unnecesary mutable variable when create COMMENT_TEMPLATES static --- src/bot/events/read_github_links.rs | 80 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/src/bot/events/read_github_links.rs b/src/bot/events/read_github_links.rs index 29bd950..56eb8e0 100644 --- a/src/bot/events/read_github_links.rs +++ b/src/bot/events/read_github_links.rs @@ -6,47 +6,45 @@ use std::collections::{HashMap, HashSet}; use std::option::Option; lazy_static! { - static ref COMMENT_TEMPLATES: HashMap<&'static str, &'static str> = { - let mut m = HashMap::new(); - m.insert("c", "// {}"); - m.insert("cpp", "// {}"); - m.insert("cs", "// {}"); - m.insert("java", "// {}"); - m.insert("js", "// {}"); - m.insert("go", "// {}"); - m.insert("kt", "// {}"); - m.insert("swift", "// {}"); - m.insert("rs", "// {}"); - m.insert("scala", "// {}"); - m.insert("py", "# {}"); - m.insert("sh", "# {}"); - m.insert("pl", "# {}"); - m.insert("rb", "# {}"); - m.insert("r", "# {}"); - m.insert("ps1", "# {}"); - m.insert("php", "// {}"); - m.insert("sql", "-- {}"); - m.insert("html", ""); - m.insert("xml", ""); - m.insert("css", "/* {} */"); - m.insert("lisp", "; {}"); - m.insert("scm", "; {}"); - m.insert("hs", "-- {}"); - m.insert("m", "% {}"); - m.insert("asm", "; {}"); - m.insert("pro", "% {}"); - m.insert("vim", "\" {}"); - m.insert("ini", "; {}"); - m.insert("jl", "# {}"); - m.insert("erl", "% {}"); - m.insert("ex", "# {}"); - m.insert("lua", "-- {}"); - m.insert("tcl", "# {}"); - m.insert("yml", "# {}"); - m.insert("md", "[comment]: # ({})"); - m.insert("lhs", "-- {}"); - m - }; + static ref COMMENT_TEMPLATES: HashMap<&'static str, &'static str> = HashMap::from([ + ("c", "// {}"), + ("cpp", "// {}"), + ("cs", "// {}"), + ("java", "// {}"), + ("js", "// {}"), + ("go", "// {}"), + ("kt", "// {}"), + ("swift", "// {}"), + ("rs", "// {}"), + ("scala", "// {}"), + ("py", "# {}"), + ("sh", "# {}"), + ("pl", "# {}"), + ("rb", "# {}"), + ("r", "# {}"), + ("ps1", "# {}"), + ("php", "// {}"), + ("sql", "-- {}"), + ("html", ""), + ("xml", ""), + ("css", "/* {} */"), + ("lisp", "; {}"), + ("scm", "; {}"), + ("hs", "-- {}"), + ("m", "% {}"), + ("asm", "; {}"), + ("pro", "% {}"), + ("vim", "\" {}"), + ("ini", "; {}"), + ("jl", "# {}"), + ("erl", "% {}"), + ("ex", "# {}"), + ("lua", "-- {}"), + ("tcl", "# {}"), + ("yml", "# {}"), + ("md", "[comment]: # ({})"), + ("lhs", "-- {}"), + ]); } pub enum RangeOrIndex { From ea6967a6602bbbd267e41663a6fb8ee83be1240e Mon Sep 17 00:00:00 2001 From: Nat <126206823+thenatx@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:53:05 -0500 Subject: [PATCH 2/4] Chore: remove the unnecessary use of lazy_static macro --- src/bot/events/read_github_links.rs | 81 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/src/bot/events/read_github_links.rs b/src/bot/events/read_github_links.rs index 56eb8e0..04b5ddf 100644 --- a/src/bot/events/read_github_links.rs +++ b/src/bot/events/read_github_links.rs @@ -1,51 +1,48 @@ -use lazy_static::lazy_static; use poise::serenity_prelude::{Context, CreateMessage, Message, MESSAGE_CODE_LIMIT}; use regex::{Captures, Regex}; use reqwest::get; use std::collections::{HashMap, HashSet}; use std::option::Option; -lazy_static! { - static ref COMMENT_TEMPLATES: HashMap<&'static str, &'static str> = HashMap::from([ - ("c", "// {}"), - ("cpp", "// {}"), - ("cs", "// {}"), - ("java", "// {}"), - ("js", "// {}"), - ("go", "// {}"), - ("kt", "// {}"), - ("swift", "// {}"), - ("rs", "// {}"), - ("scala", "// {}"), - ("py", "# {}"), - ("sh", "# {}"), - ("pl", "# {}"), - ("rb", "# {}"), - ("r", "# {}"), - ("ps1", "# {}"), - ("php", "// {}"), - ("sql", "-- {}"), - ("html", ""), - ("xml", ""), - ("css", "/* {} */"), - ("lisp", "; {}"), - ("scm", "; {}"), - ("hs", "-- {}"), - ("m", "% {}"), - ("asm", "; {}"), - ("pro", "% {}"), - ("vim", "\" {}"), - ("ini", "; {}"), - ("jl", "# {}"), - ("erl", "% {}"), - ("ex", "# {}"), - ("lua", "-- {}"), - ("tcl", "# {}"), - ("yml", "# {}"), - ("md", "[comment]: # ({})"), - ("lhs", "-- {}"), - ]); -} +static ref COMMENT_TEMPLATES: HashMap<&'static str, &'static str> = HashMap::from([ + ("c", "// {}"), + ("cpp", "// {}"), + ("cs", "// {}"), + ("java", "// {}"), + ("js", "// {}"), + ("go", "// {}"), + ("kt", "// {}"), + ("swift", "// {}"), + ("rs", "// {}"), + ("scala", "// {}"), + ("py", "# {}"), + ("sh", "# {}"), + ("pl", "# {}"), + ("rb", "# {}"), + ("r", "# {}"), + ("ps1", "# {}"), + ("php", "// {}"), + ("sql", "-- {}"), + ("html", ""), + ("xml", ""), + ("css", "/* {} */"), + ("lisp", "; {}"), + ("scm", "; {}"), + ("hs", "-- {}"), + ("m", "% {}"), + ("asm", "; {}"), + ("pro", "% {}"), + ("vim", "\" {}"), + ("ini", "; {}"), + ("jl", "# {}"), + ("erl", "% {}"), + ("ex", "# {}"), + ("lua", "-- {}"), + ("tcl", "# {}"), + ("yml", "# {}"), + ("md", "[comment]: # ({})"), + ("lhs", "-- {}"), +]); pub enum RangeOrIndex { Language(String), From d1c51b1b0715d462ac1ba238dc144faea68669b0 Mon Sep 17 00:00:00 2001 From: Nat <126206823+thenatx@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:56:21 -0500 Subject: [PATCH 3/4] Chore: remove the lazy_static dependency from Cargo.toml --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 105bc23..6edf071 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ anyhow = "1.0.66" axum = "0.7.5" chrono = "0.4.38" color-eyre = "0.6.2" -lazy_static = "1.4.0" parking_lot = { version = "0.12", features = ["send_guard"] } poise = "0.6.1" reqwest = { version = "0.11.27", features = ["json"] } # Version used by songbird::input::YoutubeDl From 87291314d9ce57ea444ba10f2fd887ddbd422d28 Mon Sep 17 00:00:00 2001 From: Nat <126206823+thenatx@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:01:23 -0500 Subject: [PATCH 4/4] Fix: Remove ref keyword use --- src/bot/events/read_github_links.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot/events/read_github_links.rs b/src/bot/events/read_github_links.rs index 04b5ddf..1f80870 100644 --- a/src/bot/events/read_github_links.rs +++ b/src/bot/events/read_github_links.rs @@ -4,7 +4,7 @@ use reqwest::get; use std::collections::{HashMap, HashSet}; use std::option::Option; -static ref COMMENT_TEMPLATES: HashMap<&'static str, &'static str> = HashMap::from([ +static COMMENT_TEMPLATES: HashMap<&'static str, &'static str> = HashMap::from([ ("c", "// {}"), ("cpp", "// {}"), ("cs", "// {}"),