diff options
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 40 |
1 files changed, 22 insertions, 18 deletions
@@ -84,11 +84,11 @@ impl Theme { }) } - pub fn name(&self) -> Cow<'static, str> { + pub fn name(&self) -> &str { match self { - Self::Dark => "Dark".into(), - Self::Light => "Light".into(), - Self::Custom(custom) => custom.name.clone(), + Self::Dark => "Dark", + Self::Light => "Light", + Self::Custom(custom) => &custom.name, } } @@ -116,6 +116,21 @@ impl std::fmt::Display for Theme { } impl Base for Theme { + fn default(preference: Mode) -> Self { + match preference { + Mode::None | Mode::Dark => Self::Dark, + Mode::Light => Self::Light, + } + } + + fn mode(&self) -> Mode { + if self.is_dark() { + Mode::Dark + } else { + Mode::Light + } + } + fn base(&self) -> Style { Style { background_color: self.colors().surface.color, @@ -136,19 +151,8 @@ impl Base for Theme { }) } - fn default(preference: Mode) -> Self { - match preference { - Mode::None | Mode::Dark => Self::Dark, - Mode::Light => Self::Light, - } - } - - fn mode(&self) -> Mode { - if self.is_dark() { - Mode::Dark - } else { - Mode::Light - } + fn name(&self) -> &str { + self.name() } } @@ -207,7 +211,7 @@ impl From<Theme> for Custom { match theme { Theme::Custom(custom) => custom, theme => Self { - name: theme.name(), + name: theme.name().to_owned().into(), is_dark: theme.is_dark(), colorscheme: theme.colors(), }, |
