From bbdafc3e121942c95ba81db1cba30fe438d88dfb Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Sun, 7 Apr 2019 13:27:25 +0200 Subject: Use strum to reduce boilerplate on ColorScheme enum + removed useless Debug derives --- src/themes.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'src/themes.rs') diff --git a/src/themes.rs b/src/themes.rs index 8635c8f..328a2e8 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -3,7 +3,7 @@ use structopt::clap::{_clap_count_exprs, arg_enum}; use strum_macros::EnumIter; arg_enum! { - #[derive(Debug, Deserialize, Clone, EnumIter)] + #[derive(PartialEq, Deserialize, Clone, EnumIter)] #[serde(rename_all = "lowercase")] pub enum ColorScheme { Archlinux, @@ -15,7 +15,9 @@ arg_enum! { impl ColorScheme { /// Returns the URL-compatible name of a color scheme - pub fn to_string(&self) -> String { + /// This must correspond to the name of the variant, in lowercase + /// See https://github.com/svenstaro/miniserve/pull/55 for explanations + pub fn to_slug(&self) -> String { match &self { ColorScheme::Archlinux => "archlinux", ColorScheme::Zenburn => "zenburn", @@ -35,17 +37,6 @@ impl ColorScheme { } } - /// Returns the name of a color scheme - pub fn get_name(&self) -> String { - match &self { - ColorScheme::Archlinux => "Archlinux", - ColorScheme::Zenburn => "Zenburn", - ColorScheme::Monokai => "Monokai", - ColorScheme::Squirrel => "Squirrel", - } - .to_string() - } - /// Retrieves the color palette associated to a color scheme pub fn get_theme(self) -> Theme { match self { -- cgit v1.2.3