diff options
author | Narawit Rakket <narawitrakket@hotmail.com> | 2022-08-07 16:41:30 +0700 |
---|---|---|
committer | Abin Simon <abinsimon10@gmail.com> | 2022-08-07 19:53:37 +0530 |
commit | 1553aafe9db589dfe9d0385a2111127060af8db8 (patch) | |
tree | 23d939722ac9bdc4f0066210fccf0ed59f696687 | |
parent | 685d5a6c2f6ce45e9bc16246a25f5971559f9a99 (diff) |
refactor: simplify panic message in `unreachable!`
Mention `clap` in the comment instead because this information is
useful for developers but can confuse users
-rw-r--r-- | src/flags/color.rs | 7 | ||||
-rw-r--r-- | src/flags/hyperlink.rs | 5 | ||||
-rw-r--r-- | src/flags/icons.rs | 12 | ||||
-rw-r--r-- | src/flags/permission.rs | 7 | ||||
-rw-r--r-- | src/flags/size.rs | 5 | ||||
-rw-r--r-- | src/flags/sorting.rs | 7 |
6 files changed, 14 insertions, 29 deletions
diff --git a/src/flags/color.rs b/src/flags/color.rs index 428be8e..ac01491 100644 --- a/src/flags/color.rs +++ b/src/flags/color.rs @@ -106,11 +106,8 @@ impl ColorOption { "always" => Self::Always, "auto" => Self::Auto, "never" => Self::Never, - other => { - unreachable!( - "Invalid value '{other}' for 'color' flag should be handled by `clap`" - ); - } + // Invalid value should be handled by `clap` when building an `ArgMatches` + other => unreachable!("Invalid value '{other}' for 'color'"), } } } diff --git a/src/flags/hyperlink.rs b/src/flags/hyperlink.rs index 82aa314..04d58bc 100644 --- a/src/flags/hyperlink.rs +++ b/src/flags/hyperlink.rs @@ -23,9 +23,8 @@ impl HyperlinkOption { "always" => Self::Always, "auto" => Self::Auto, "never" => Self::Never, - other => unreachable!( - "Invalid value '{other}' for 'hyperlink' flag should be handled by `clap`" - ), + // Invalid value should be handled by `clap` when building an `ArgMatches` + other => unreachable!("Invalid value '{other}' for 'hyperlink'"), } } } diff --git a/src/flags/icons.rs b/src/flags/icons.rs index 4f6122d..b481e91 100644 --- a/src/flags/icons.rs +++ b/src/flags/icons.rs @@ -51,9 +51,8 @@ impl IconOption { "always" => Self::Always, "auto" => Self::Auto, "never" => Self::Never, - other => { - unreachable!("Invalid value '{other}' for 'icon' flag should be handled by `clap`"); - } + // Invalid value should be handled by `clap` when building an `ArgMatches` + other => unreachable!("Invalid value '{other}' for 'icon'"), } } } @@ -109,11 +108,8 @@ impl IconTheme { match value { "fancy" => Self::Fancy, "unicode" => Self::Unicode, - other => { - unreachable!( - "Invalid value '{other}' for 'icon-theme' flag should be handled by `clap`" - ); - } + // Invalid value should be handled by `clap` when building an `ArgMatches` + other => unreachable!("Invalid value '{other}' for 'icon-theme'"), } } } diff --git a/src/flags/permission.rs b/src/flags/permission.rs index 6b25b3a..7f9838f 100644 --- a/src/flags/permission.rs +++ b/src/flags/permission.rs @@ -23,11 +23,8 @@ impl PermissionFlag { match value { "rwx" => Self::Rwx, "octal" => Self::Octal, - other => { - unreachable!( - "Invalid value '{other}' for 'permission' flag should be handled by `clap`" - ); - } + // Invalid value should be handled by `clap` when building an `ArgMatches` + other => unreachable!("Invalid value '{other}' for 'permission'"), } } } diff --git a/src/flags/size.rs b/src/flags/size.rs index 2ab3460..054098e 100644 --- a/src/flags/size.rs +++ b/src/flags/size.rs @@ -26,9 +26,8 @@ impl SizeFlag { "default" => Self::Default, "short" => Self::Short, "bytes" => Self::Bytes, - other => { - unreachable!("Invalid value '{other}' for 'size' flag should be handled by `clap`"); - } + // Invalid value should be handled by `clap` when building an `ArgMatches` + other => unreachable!("Invalid value '{other}' for 'size'"), } } } diff --git a/src/flags/sorting.rs b/src/flags/sorting.rs index 011e71d..10864da 100644 --- a/src/flags/sorting.rs +++ b/src/flags/sorting.rs @@ -142,11 +142,8 @@ impl DirGrouping { "first" => Self::First, "last" => Self::Last, "none" => Self::None, - other => { - unreachable!( - "Invalid value '{other}' for 'group-dirs' flag should be handled by `clap`" - ); - } + // Invalid value should be handled by `clap` when building an `ArgMatches` + other => unreachable!("Invalid value '{other}' for 'group-dirs'"), } } } |