refactor(parser): Tweak specialization precedence

In theory, directly implemented types should have higher precedence than
inferring from another trait.
This commit is contained in:
Ed Page 2022-05-13 09:38:07 -05:00
parent 50e7308c22
commit 352025f8cb

View file

@ -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>