summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarawit Rakket <narawitrakket@hotmail.com>2022-08-12 23:42:34 +0700
committerAbin Simon <abinsimon10@gmail.com>2022-08-12 22:54:17 +0530
commit08626b84fcf5d21e3435eec1d8cf636be3e947f5 (patch)
tree628203623a977b274211abed5070ddf9fb1c3cd3
parentb529b6a901441d95544b03ec1736b7e4c4d59950 (diff)
refactor(icon): minor refactoring
* use `matches!` to improve readability * remove unnecessary `format!` in tests
-rw-r--r--src/icon.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/icon.rs b/src/icon.rs
index cb2dcc3..c051c1e 100644
--- a/src/icon.rs
+++ b/src/icon.rs
@@ -23,7 +23,7 @@ pub enum Theme {
// s#\\u[0-9a-f]*#\=eval('"'.submatch(0).'"')#
impl Icons {
pub fn new(theme: Theme, icon_separator: String) -> Self {
- let display_icons = theme == Theme::Fancy || theme == Theme::Unicode;
+ let display_icons = matches!(theme, Theme::Fancy | Theme::Unicode);
let (icons_by_name, icons_by_extension, default_file_icon, default_folder_icon) =
if theme == Theme::Fancy {
(
@@ -511,7 +511,7 @@ mod test {
let icon = Icons::new(Theme::Fancy, " ".to_string());
let icon_str = icon.get(&meta.name);
- assert_eq!(icon_str, format!("{}{}", "\u{f016}", icon.icon_separator)); // 
+ assert_eq!(icon_str, "\u{f016} "); // 
}
#[test]
@@ -524,7 +524,7 @@ mod test {
let icon = Icons::new(Theme::Unicode, " ".to_string());
let icon_str = icon.get(&meta.name);
- assert_eq!(icon_str, format!("{}{}", "\u{1f5cb}", icon.icon_separator));
+ assert_eq!(icon_str, "\u{1f5cb} ");
}
#[test]
@@ -536,7 +536,7 @@ mod test {
let icon = Icons::new(Theme::Fancy, " ".to_string());
let icon_str = icon.get(&meta.name);
- assert_eq!(icon_str, format!("{}{}", "\u{f115}", icon.icon_separator)); // 
+ assert_eq!(icon_str, "\u{f115} "); // 
}
#[test]
@@ -548,7 +548,7 @@ mod test {
let icon = Icons::new(Theme::Unicode, " ".to_string());
let icon_str = icon.get(&meta.name);
- assert_eq!(icon_str, format!("{}{}", "\u{1f5c1}", icon.icon_separator));
+ assert_eq!(icon_str, "\u{1f5c1} ");
}
#[test]
@@ -560,7 +560,7 @@ mod test {
let icon = Icons::new(Theme::Fancy, " ".to_string());
let icon_str = icon.get(&meta.name);
- assert_eq!(icon_str, format!("{}{}", "\u{f115}", icon.icon_separator)); // 
+ assert_eq!(icon_str, "\u{f115} "); // 
}
#[test]