diff options
author | Rustin-Liu <rustin.liu@gmail.com> | 2019-11-07 21:14:56 +0800 |
---|---|---|
committer | Tim Oram <dev@mitmaro.ca> | 2019-11-07 13:31:13 -0330 |
commit | d5ab27bc09e604b46390abe3146cea94a28e33fb (patch) | |
tree | 9bf2a8c40204674d9ceb130ff15f53efae5a47ec | |
parent | d27934f7bd57929b75154ab0f1e5c196eacd5421 (diff) |
refactoring code replace if with match
-rw-r--r-- | src/help/utils.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/help/utils.rs b/src/help/utils.rs index f3589ae..b94b8ba 100644 --- a/src/help/utils.rs +++ b/src/help/utils.rs @@ -2,20 +2,12 @@ use crate::Config; use unicode_segmentation::UnicodeSegmentation; fn get_input_short_name(input: &str) -> String { - if input == "PageUp" { - String::from("PgUp") - } - else if input == "PageDown" { - String::from("PgDn") - } - else if input == "Resize" { - String::from("Rsze") - } - else if input == "Other" { - String::from("Oth") - } - else { - String::from(input) + match input { + "PageUp" => String::from("PgUp"), + "PageDown" => String::from("PgDn"), + "Resize" => String::from("Rsze"), + "Other" => String::from("Oth"), + _ => String::from(input), } } |