diff options
author | sushi-shi <47691267+sushi-shi@users.noreply.github.com> | 2022-02-25 03:56:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-24 19:56:32 -0500 |
commit | 5451fd9865f2a75d623992a072eb639ea20e688f (patch) | |
tree | fca079a571f8fe01dc72c9a05daf6efcea18e091 /src/config | |
parent | 55b401cfa35ee3ce09d2deba94f0d490ad666e9b (diff) |
Fix clippy warnings (#144)
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/general/app.rs | 2 | ||||
-rw-r--r-- | src/config/general/app_crude.rs | 2 | ||||
-rw-r--r-- | src/config/mimetype/registry.rs | 12 | ||||
-rw-r--r-- | src/config/option/sort_option.rs | 2 | ||||
-rw-r--r-- | src/config/preview.rs | 25 | ||||
-rw-r--r-- | src/config/theme/app_theme.rs | 19 |
6 files changed, 10 insertions, 52 deletions
diff --git a/src/config/general/app.rs b/src/config/general/app.rs index 41bb604..c21c10d 100644 --- a/src/config/general/app.rs +++ b/src/config/general/app.rs @@ -31,7 +31,7 @@ impl AppConfig { pub fn preview_options_ref(&self) -> &PreviewOption { &self._preview_options } - pub fn preview_options_mut(&mut self) -> &mut PreviewOption { + pub fn _preview_options_mut(&mut self) -> &mut PreviewOption { &mut self._preview_options } diff --git a/src/config/general/app_crude.rs b/src/config/general/app_crude.rs index 1598427..cd7bc78 100644 --- a/src/config/general/app_crude.rs +++ b/src/config/general/app_crude.rs @@ -52,6 +52,6 @@ impl From<AppConfigCrude> for AppConfig { impl TomlConfigFile for AppConfig { fn get_config(file_name: &str) -> Self { - parse_to_config_file::<AppConfigCrude, AppConfig>(file_name).unwrap_or_else(Self::default) + parse_to_config_file::<AppConfigCrude, AppConfig>(file_name).unwrap_or_default() } } diff --git a/src/config/mimetype/registry.rs b/src/config/mimetype/registry.rs index 26ba824..73c20ac 100644 --- a/src/config/mimetype/registry.rs +++ b/src/config/mimetype/registry.rs @@ -15,7 +15,7 @@ pub struct AppMimetypeRegistryCrude { pub _extension: MimetypeRegistry, } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct AppMimetypeRegistry { // pub _class: HashMap<String, Vec<AppMimetypeEntry>>, pub _extension: MimetypeRegistry, @@ -54,17 +54,9 @@ impl From<AppMimetypeRegistryCrude> for AppMimetypeRegistry { } } -impl std::default::Default for AppMimetypeRegistry { - fn default() -> Self { - Self { - _extension: MimetypeRegistry::new(), - } - } -} - impl TomlConfigFile for AppMimetypeRegistry { fn get_config(file_name: &str) -> Self { parse_to_config_file::<AppMimetypeRegistryCrude, AppMimetypeRegistry>(file_name) - .unwrap_or_else(Self::default) + .unwrap_or_default() } } diff --git a/src/config/option/sort_option.rs b/src/config/option/sort_option.rs index edf3a6f..5b41020 100644 --- a/src/config/option/sort_option.rs +++ b/src/config/option/sort_option.rs @@ -29,7 +29,7 @@ impl SortOption { } // let mut res = self.sort_method.cmp(f1, f2, &self); - let mut res = self.sort_methods.cmp(f1, f2, &self); + let mut res = self.sort_methods.cmp(f1, f2, self); if self.reverse { res = match res { cmp::Ordering::Less => cmp::Ordering::Greater, diff --git a/src/config/preview.rs b/src/config/preview.rs index 62883c8..7d0b0be 100644 --- a/src/config/preview.rs +++ b/src/config/preview.rs @@ -9,21 +9,12 @@ pub struct JoshutoPreviewEntry { pub args: Option<Vec<String>>, } -#[derive(Debug, Deserialize)] +#[derive(Debug, Default, Deserialize)] struct JoshutoPreviewCrude { pub extension: Option<HashMap<String, JoshutoPreviewEntry>>, pub mimetype: Option<HashMap<String, JoshutoPreviewEntry>>, } -impl std::default::Default for JoshutoPreviewCrude { - fn default() -> Self { - Self { - extension: None, - mimetype: None, - } - } -} - impl From<JoshutoPreviewCrude> for JoshutoPreview { fn from(crude: JoshutoPreviewCrude) -> Self { let extension = crude.extension.unwrap_or_default(); @@ -36,7 +27,7 @@ impl From<JoshutoPreviewCrude> for JoshutoPreview { } } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct JoshutoPreview { pub extension: HashMap<String, JoshutoPreviewEntry>, pub mimetype: HashMap<String, JoshutoPreviewEntry>, @@ -44,16 +35,6 @@ pub struct JoshutoPreview { impl TomlConfigFile for JoshutoPreview { fn get_config(file_name: &str) -> Self { - parse_to_config_file::<JoshutoPreviewCrude, JoshutoPreview>(file_name) - .unwrap_or_else(JoshutoPreview::default) - } -} - -impl std::default::Default for JoshutoPreview { - fn default() -> Self { - JoshutoPreview { - extension: HashMap::new(), - mimetype: HashMap::new(), - } + parse_to_config_file::<JoshutoPreviewCrude, JoshutoPreview>(file_name).unwrap_or_default() } } diff --git a/src/config/theme/app_theme.rs b/src/config/theme/app_theme.rs index 96a9012..5609db9 100644 --- a/src/config/theme/app_theme.rs +++ b/src/config/theme/app_theme.rs @@ -6,7 +6,7 @@ use super::{AppStyle, RawAppStyle}; use crate::config::{parse_to_config_file, TomlConfigFile}; use crate::error::JoshutoResult; -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize, Default)] pub struct AppThemeCrude { #[serde(default)] pub regular: RawAppStyle, @@ -26,21 +26,6 @@ pub struct AppThemeCrude { pub ext: HashMap<String, RawAppStyle>, } -impl std::default::Default for AppThemeCrude { - fn default() -> Self { - Self { - regular: RawAppStyle::default(), - selection: RawAppStyle::default(), - directory: RawAppStyle::default(), - executable: RawAppStyle::default(), - link: RawAppStyle::default(), - link_invalid: RawAppStyle::default(), - socket: RawAppStyle::default(), - ext: HashMap::default(), - } - } -} - impl From<AppThemeCrude> for AppTheme { fn from(crude: AppThemeCrude) -> Self { let selection = crude.selection.to_style_theme(); @@ -93,7 +78,7 @@ impl AppTheme { impl TomlConfigFile for AppTheme { fn get_config(file_name: &str) -> Self { - parse_to_config_file::<AppThemeCrude, AppTheme>(file_name).unwrap_or_else(Self::default) + parse_to_config_file::<AppThemeCrude, AppTheme>(file_name).unwrap_or_default() } } |