From 9baac849e54a6f8c0d54b22fed143bbf8d965f23 Mon Sep 17 00:00:00 2001 From: chris west Date: Sun, 13 Nov 2022 22:07:20 -0800 Subject: [PATCH] thanks clippy --- src/main.rs | 2 +- src/menu.rs | 2 +- src/theme.rs | 37 +++++++++++++++++++------------------ 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/main.rs b/src/main.rs index 72dd013..743c375 100644 --- a/src/main.rs +++ b/src/main.rs @@ -143,7 +143,7 @@ fn print_plain(url: &str, tls: bool, tor: bool) -> Result<(), Box> { /// Print current theme as plaintext fn print_theme(cfg: Config) -> Result<(), Box> { - println!("{}", cfg.theme.to_string()); + println!("{}", cfg.theme); Ok(()) } diff --git a/src/menu.rs b/src/menu.rs index 5341780..936bf65 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -983,7 +983,7 @@ pub fn parse(url: &str, raw: String, config: Config) -> Menu { tor: false, wide: false, scroll: 0, - config: config, + config, } } diff --git a/src/theme.rs b/src/theme.rs index 53d467c..d74064c 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -1,5 +1,6 @@ //! Terminal color scheme. //! Provides the Theme struct and functions/macros for making use of it. +use std::fmt; /// Provides a shortcut to the Reset color code. pub mod color { @@ -59,28 +60,28 @@ pub struct Theme { impl Default for Theme { fn default() -> Theme { Theme { - ui_cursor: to_color("white bold").into(), - ui_number: to_color("magenta").into(), - ui_menu: to_color("yellow").into(), - ui_text: to_color("white").into(), - - item_text: to_color("cyan").into(), - item_menu: to_color("blue").into(), - item_error: to_color("red").into(), - item_search: to_color("white").into(), - item_telnet: to_color("grey").into(), - item_external: to_color("green").into(), - item_download: to_color("white underline").into(), - item_media: to_color("green underline").into(), - item_unsupported: to_color("whitebg red").into(), + ui_cursor: to_color("white bold"), + ui_number: to_color("magenta"), + ui_menu: to_color("yellow"), + ui_text: to_color("white"), + + item_text: to_color("cyan"), + item_menu: to_color("blue"), + item_error: to_color("red"), + item_search: to_color("white"), + item_telnet: to_color("grey"), + item_external: to_color("green"), + item_download: to_color("white underline"), + item_media: to_color("green underline"), + item_unsupported: to_color("whitebg red"), } } } -impl Theme { - /// Return theme file for this theme - pub fn to_string(&self) -> String { - format!( +impl fmt::Display for Theme { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, "# phetch theme ui.cursor {ui_cursor} ui.number {ui_number}