Your Name 1 жил өмнө
parent
commit
3fd4d228be
1 өөрчлөгдсөн 9 нэмэгдсэн , 3 устгасан
  1. 9 3
      src/theme.rs

+ 9 - 3
src/theme.rs

@@ -2,7 +2,7 @@ use std::collections::HashMap;
 
 #[derive(Debug)]
 pub struct Colors {
-    pub map: HashMap<String, String>,
+    pub inner: HashMap<String, String>,
 }
 
 impl Default for Colors {
@@ -16,10 +16,16 @@ impl Default for Colors {
             ("blue", "#669bbc"),
             ("dark_blue", "#003049"),
         ];
-        let map: HashMap<_, _> = def
+        let inner: HashMap<_, _> = def
             .into_iter()
             .map(|(k, v)| (k.to_string(), v.to_string()))
             .collect();
-        Self { map }
+        Self { inner }
+    }
+}
+
+impl Colors {
+    pub fn get(&self, key: &str) -> String {
+        self.inner.get(key).cloned().unwrap_or_else(|| "#669bbc".to_string())
     }
 }