mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
refactor(parser): Tweak specialization precedence
In theory, directly implemented types should have higher precedence than inferring from another trait.
This commit is contained in:
parent
50e7308c22
commit
352025f8cb
1 changed files with 27 additions and 27 deletions
|
@ -629,6 +629,26 @@ impl<T> AutoValueParser<T> {
|
|||
pub mod via_prelude {
|
||||
use super::*;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait ValueParserViaBuiltIn: private::ValueParserViaBuiltInSealed {
|
||||
fn value_parser(&self) -> ValueParser;
|
||||
}
|
||||
impl ValueParserViaBuiltIn for &&AutoValueParser<String> {
|
||||
fn value_parser(&self) -> ValueParser {
|
||||
ValueParser::string()
|
||||
}
|
||||
}
|
||||
impl ValueParserViaBuiltIn for &&AutoValueParser<std::ffi::OsString> {
|
||||
fn value_parser(&self) -> ValueParser {
|
||||
ValueParser::os_string()
|
||||
}
|
||||
}
|
||||
impl ValueParserViaBuiltIn for &&AutoValueParser<std::path::PathBuf> {
|
||||
fn value_parser(&self) -> ValueParser {
|
||||
ValueParser::path_buf()
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait ValueParserViaArgEnum: private::ValueParserViaArgEnumSealed {
|
||||
type Output;
|
||||
|
@ -636,7 +656,7 @@ pub mod via_prelude {
|
|||
fn value_parser(&self) -> Self::Output;
|
||||
}
|
||||
impl<E: crate::ArgEnum + Clone + Send + Sync + 'static> ValueParserViaArgEnum
|
||||
for &&AutoValueParser<E>
|
||||
for &AutoValueParser<E>
|
||||
{
|
||||
type Output = ArgEnumValueParser<E>;
|
||||
|
||||
|
@ -645,26 +665,6 @@ pub mod via_prelude {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait ValueParserViaBuiltIn: private::ValueParserViaBuiltInSealed {
|
||||
fn value_parser(&self) -> ValueParser;
|
||||
}
|
||||
impl ValueParserViaBuiltIn for &AutoValueParser<String> {
|
||||
fn value_parser(&self) -> ValueParser {
|
||||
ValueParser::string()
|
||||
}
|
||||
}
|
||||
impl ValueParserViaBuiltIn for &AutoValueParser<std::ffi::OsString> {
|
||||
fn value_parser(&self) -> ValueParser {
|
||||
ValueParser::os_string()
|
||||
}
|
||||
}
|
||||
impl ValueParserViaBuiltIn for &AutoValueParser<std::path::PathBuf> {
|
||||
fn value_parser(&self) -> ValueParser {
|
||||
ValueParser::path_buf()
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait ValueParserViaFromStr: private::ValueParserViaFromStrSealed {
|
||||
fn value_parser(&self) -> ValueParser;
|
||||
|
@ -715,13 +715,13 @@ mod private {
|
|||
{
|
||||
}
|
||||
|
||||
pub trait ValueParserViaArgEnumSealed {}
|
||||
impl<E: crate::ArgEnum> ValueParserViaArgEnumSealed for &&super::AutoValueParser<E> {}
|
||||
|
||||
pub trait ValueParserViaBuiltInSealed {}
|
||||
impl ValueParserViaBuiltInSealed for &super::AutoValueParser<String> {}
|
||||
impl ValueParserViaBuiltInSealed for &super::AutoValueParser<std::ffi::OsString> {}
|
||||
impl ValueParserViaBuiltInSealed for &super::AutoValueParser<std::path::PathBuf> {}
|
||||
impl ValueParserViaBuiltInSealed for &&super::AutoValueParser<String> {}
|
||||
impl ValueParserViaBuiltInSealed for &&super::AutoValueParser<std::ffi::OsString> {}
|
||||
impl ValueParserViaBuiltInSealed for &&super::AutoValueParser<std::path::PathBuf> {}
|
||||
|
||||
pub trait ValueParserViaArgEnumSealed {}
|
||||
impl<E: crate::ArgEnum> ValueParserViaArgEnumSealed for &super::AutoValueParser<E> {}
|
||||
|
||||
pub trait ValueParserViaFromStrSealed {}
|
||||
impl<FromStr> ValueParserViaFromStrSealed for super::AutoValueParser<FromStr>
|
||||
|
|
Loading…
Reference in a new issue