From bc3beccbf64ecafac58a0b06f567a6a698900ec4 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Wed, 25 May 2022 17:25:53 +0100 Subject: [PATCH] hashmap change --- lapce-data/src/config.rs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/lapce-data/src/config.rs b/lapce-data/src/config.rs index f2d3cd2e..0ae08685 100644 --- a/lapce-data/src/config.rs +++ b/lapce-data/src/config.rs @@ -10,9 +10,9 @@ piet::{PietText, Text, TextLayout, TextLayoutBuilder}, Color, ExtEventSink, FontFamily, Size, Target, }; -use hashbrown::HashMap; use parking_lot::RwLock; use serde::{Deserialize, Serialize}; +use std::collections::HashMap; use structdesc::FieldNames; use thiserror::Error; @@ -252,16 +252,16 @@ pub struct ThemeConfig { pub path: PathBuf, pub name: String, pub base: ThemeBaseConfig, - pub syntax: std::collections::HashMap, - pub ui: std::collections::HashMap, + pub syntax: HashMap, + pub ui: HashMap, } impl ThemeConfig { fn resolve_color( - colors: &std::collections::HashMap, + colors: &HashMap, base: &ThemeBaseColor, - default: Option<&std::collections::HashMap>, - ) -> std::collections::HashMap { + default: Option<&HashMap>, + ) -> HashMap { colors .iter() .map(|(name, hex)| { @@ -293,16 +293,16 @@ fn resolve_color( fn resolve_ui_color( &self, base: &ThemeBaseColor, - default: Option<&std::collections::HashMap>, - ) -> std::collections::HashMap { + default: Option<&HashMap>, + ) -> HashMap { Self::resolve_color(&self.ui, base, default) } fn resolve_syntax_color( &self, base: &ThemeBaseColor, - default: Option<&std::collections::HashMap>, - ) -> std::collections::HashMap { + default: Option<&HashMap>, + ) -> HashMap { Self::resolve_color(&self.syntax, base, default) } } @@ -387,8 +387,8 @@ pub fn resolve(&self, default: Option<&ThemeBaseColor>) -> ThemeBaseColor { #[derive(Debug, Clone, Default)] pub struct ThemeColor { pub base: ThemeBaseColor, - pub syntax: std::collections::HashMap, - pub ui: std::collections::HashMap, + pub syntax: HashMap, + pub ui: HashMap, } #[derive(Debug, Clone)] @@ -455,7 +455,7 @@ pub struct Config { #[serde(skip)] pub color: ThemeColor, #[serde(skip)] - pub available_themes: std::collections::HashMap, + pub available_themes: HashMap, #[serde(skip)] tab_layout_info: Arc>>, } @@ -568,7 +568,7 @@ fn resolve_colors(&mut self, default_config: Option<&Config>) { ); } - fn load_themes() -> std::collections::HashMap { + fn load_themes() -> HashMap { let mut themes = Self::load_local_themes().unwrap_or_default(); let (name, theme) = Self::load_theme_from_str(DEFAULT_LIGHT_THEME).unwrap(); @@ -579,10 +579,9 @@ fn load_themes() -> std::collections::HashMap { themes } - fn load_local_themes( - ) -> Option> { + fn load_local_themes() -> Option> { let themes_folder = Config::themes_folder()?; - let themes: std::collections::HashMap = + let themes: HashMap = std::fs::read_dir(themes_folder) .ok()? .filter_map(|entry| {