From e975412ea58017fd985151a7490621789c78ae47 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Sat, 5 Nov 2022 17:42:00 +0100 Subject: [PATCH] Remove `FromStr` impl for `arg` enums This is covered by clap's `ValueEnum` via derive. The `FromStr` impl is now merely a hazard of forgetting to update code. --- src/args.rs | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/args.rs b/src/args.rs index 9437d63..b8b1d80 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,5 +1,3 @@ -use std::str::FromStr; - use clap::{Parser, ValueEnum}; /// Command line arguments. @@ -171,18 +169,6 @@ impl Default for ColorSetting { } } -impl FromStr for ColorSetting { - type Err = &'static str; - fn from_str(s: &str) -> Result { - match s { - "auto" => Ok(ColorSetting::Auto), - "always" => Ok(ColorSetting::Always), - "never" => Ok(ColorSetting::Never), - _ => Err("invalid color setting"), - } - } -} - /// Possible values for the `--format` option. #[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)] pub enum FormatSetting { @@ -199,17 +185,6 @@ impl Default for FormatSetting { } } -impl FromStr for FormatSetting { - type Err = &'static str; - fn from_str(s: &str) -> Result { - match s { - "pretty" => Ok(FormatSetting::Pretty), - "terse" => Ok(FormatSetting::Terse), - _ => Err("invalid output format"), - } - } -} - #[cfg(test)] mod tests { use super::*; @@ -217,6 +192,6 @@ mod tests { #[test] fn verify_cli() { use clap::CommandFactory; - Arguments::command().debug_assert() + Arguments::command().debug_assert(); } }