diff --git a/crates/utils/src/codename.rs b/crates/utils/src/codename.rs index e2e8381..1c0e575 100644 --- a/crates/utils/src/codename.rs +++ b/crates/utils/src/codename.rs @@ -1,19 +1,25 @@ +use std::collections::HashMap; + use crate::VERSION; /// https://github.com/importantimport/hatsu/milestones pub fn codename() -> &'static str { - match String::from(VERSION) { - v if v.starts_with("0.1") => "01_ballade", - v if v.starts_with("0.2") => "celluloid", - v if v.starts_with("0.3") => "Strobe Nights", - v if v.starts_with("0.4") => "Clover Club", - v if v.starts_with("0.5") => "Sakura No Kisetsu", - v if v.starts_with("0.6") => "World Is Mine", - v if v.starts_with("0.7") => "Nisoku Hokou", - v if v.starts_with("0.8") => "Sweet Devil", - v if v.starts_with("0.9") => "Unfragment", - v if v.starts_with("1.0") => "Hoshi No Kakera", - // easter egg - _ => "Cat Food", - } + let version = String::from(VERSION); + let hashmap: HashMap<&str, &str> = HashMap::from([ + ("0.1", "01_ballade"), + ("0.2", "celluloid"), + ("0.3", "Strobe Nights"), + ("0.4", "Clover Club"), + ("0.5", "Sakura No Kisetsu"), + ("0.6", "World Is Mine"), + ("0.7", "Nisoku Hokou"), + ("0.8", "Sweet Devil"), + ("0.9", "Unfragment"), + ("1.0", "Hoshi No Kakera"), + ]); + + hashmap + .iter() + .find(|(major_minor, _)| version.starts_with(*major_minor)) + .map_or("Cat Food", |(_, codename)| codename) }