From 072903882de4e57ec297ce41606b2a98b168b153 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Fri, 22 Mar 2024 08:40:09 -0400 Subject: [PATCH] botmodule case insensitive --- src/core/botmodules.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core/botmodules.rs b/src/core/botmodules.rs index 568683a..cc4b1aa 100644 --- a/src/core/botmodules.rs +++ b/src/core/botmodules.rs @@ -272,11 +272,22 @@ pub async fn init(mgr: Arc) { -#[derive(Debug, PartialEq, Eq, Hash, Clone)] +// #[derive(Debug, PartialEq, Eq, Hash, Clone)] +#[derive(Debug, Hash, Clone)] pub enum ModType { BotModule(String), } +impl PartialEq for ModType { + fn eq(&self, other: &Self) -> bool { + let BotModule(name1) = self.clone(); + let BotModule(name2) = other.clone(); + name1.to_lowercase() == name2.to_lowercase() + } +} +impl Eq for ModType {} + + #[derive(Debug, PartialEq, Eq, Hash, Clone)] pub enum ModGroup { Core, @@ -1287,10 +1298,10 @@ mod core_modulesmanager { use super::*; #[test] - fn WIP_case_insensitive_test() { + fn case_insensitive_test() { Log::set_file_ext(Extension::Log); assert_eq!( - BotModule("test".to_string()), + BotModule("Test".to_string()), BotModule("Test".to_lowercase()) ); }