diff --git a/src/builder/value_parser.rs b/src/builder/value_parser.rs index 664497dfbf7f..c4c02ed55f66 100644 --- a/src/builder/value_parser.rs +++ b/src/builder/value_parser.rs @@ -2040,7 +2040,7 @@ pub mod via_prelude { type Parser; fn value_parser(&self) -> Self::Parser; } - impl _ValueParserViaFactory for &&&&_AutoValueParser

{ + impl _ValueParserViaFactory for &&&&&&_AutoValueParser

{ type Parser = P::Parser; fn value_parser(&self) -> Self::Parser { P::value_parser() @@ -2054,7 +2054,7 @@ pub mod via_prelude { fn value_parser(&self) -> Self::Output; } impl _ValueParserViaValueEnum - for &&&_AutoValueParser + for &&&&&_AutoValueParser { type Output = EnumValueParser; @@ -2067,7 +2067,7 @@ pub mod via_prelude { pub trait _ValueParserViaFromOsString: private::_ValueParserViaFromOsStringSealed { fn value_parser(&self) -> _AnonymousValueParser; } - impl _ValueParserViaFromOsString for &&_AutoValueParser + impl _ValueParserViaFromOsString for &&&&_AutoValueParser where FromOsString: From + std::any::Any + Clone + Send + Sync + 'static, { @@ -2087,7 +2087,7 @@ pub mod via_prelude { pub trait _ValueParserViaFromOsStr: private::_ValueParserViaFromOsStrSealed { fn value_parser(&self) -> _AnonymousValueParser; } - impl _ValueParserViaFromOsStr for &_AutoValueParser + impl _ValueParserViaFromOsStr for &&&_AutoValueParser where FromOsStr: for<'s> From<&'s std::ffi::OsStr> + std::any::Any + Clone + Send + Sync + 'static, @@ -2104,6 +2104,46 @@ pub mod via_prelude { } } + #[doc(hidden)] + pub trait _ValueParserViaFromString: private::_ValueParserViaFromStringSealed { + fn value_parser(&self) -> _AnonymousValueParser; + } + impl _ValueParserViaFromString for &&_AutoValueParser + where + FromString: From + std::any::Any + Clone + Send + Sync + 'static, + { + fn value_parser(&self) -> _AnonymousValueParser { + _AnonymousValueParser( + StringValueParser::new() + .map(|s| { + let output = FromString::from(s); + output + }) + .into(), + ) + } + } + + #[doc(hidden)] + pub trait _ValueParserViaFromStr: private::_ValueParserViaFromStrSealed { + fn value_parser(&self) -> _AnonymousValueParser; + } + impl _ValueParserViaFromStr for &_AutoValueParser + where + FromStr: for<'s> From<&'s str> + std::any::Any + Clone + Send + Sync + 'static, + { + fn value_parser(&self) -> _AnonymousValueParser { + _AnonymousValueParser( + StringValueParser::new() + .map(|s| { + let output = FromStr::from(&s); + output + }) + .into(), + ) + } + } + #[doc(hidden)] pub trait _ValueParserViaParse: private::_ValueParserViaParseSealed { fn value_parser(&self) -> _AnonymousValueParser; @@ -2129,6 +2169,7 @@ pub mod via_prelude { /// - [Ranged numeric types][RangedI64ValueParser]: `u8`, `i8`, `u16`, `i16, `u32`, `i32`, `u64`, `i64` /// - [`ValueEnum` types][crate::ValueEnum] /// - [`From<&OsString>` types][std::str::From] and [`From<&OsStr>` types][std::str::From] +/// - [`From<&String>` types][std::str::From] and [`From<&str>` types][std::str::From] /// - [`FromStr` types][std::str::FromStr], including usize, isize /// /// # Example @@ -2205,26 +2246,38 @@ mod private { // Prefer these so `clap_derive` defaults to optimized implementations pub trait _ValueParserViaSelfSealed {} - impl> _ValueParserViaSelfSealed for &&&&&_AutoValueParser

{} + impl> _ValueParserViaSelfSealed for &&&&&&&_AutoValueParser

{} pub trait _ValueParserViaFactorySealed {} - impl _ValueParserViaFactorySealed for &&&&_AutoValueParser

{} + impl _ValueParserViaFactorySealed for &&&&&&_AutoValueParser

{} pub trait _ValueParserViaValueEnumSealed {} - impl _ValueParserViaValueEnumSealed for &&&_AutoValueParser {} + impl _ValueParserViaValueEnumSealed for &&&&&_AutoValueParser {} pub trait _ValueParserViaFromOsStringSealed {} - impl _ValueParserViaFromOsStringSealed for &&_AutoValueParser where + impl _ValueParserViaFromOsStringSealed for &&&&_AutoValueParser where FromOsString: From + std::any::Any + Send + Sync + 'static { } pub trait _ValueParserViaFromOsStrSealed {} - impl _ValueParserViaFromOsStrSealed for &_AutoValueParser where + impl _ValueParserViaFromOsStrSealed for &&&_AutoValueParser where FromOsStr: for<'s> From<&'s std::ffi::OsStr> + std::any::Any + Send + Sync + 'static { } + pub trait _ValueParserViaFromStringSealed {} + impl _ValueParserViaFromStringSealed for &&_AutoValueParser where + FromString: From + std::any::Any + Send + Sync + 'static + { + } + + pub trait _ValueParserViaFromStrSealed {} + impl _ValueParserViaFromStrSealed for &_AutoValueParser where + FromStr: for<'s> From<&'s str> + std::any::Any + Send + Sync + 'static + { + } + pub trait _ValueParserViaParseSealed {} impl _ValueParserViaParseSealed for _AutoValueParser where