mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
refactor(parser): Minor clean up
This commit is contained in:
parent
352025f8cb
commit
f9be3215c1
1 changed files with 14 additions and 6 deletions
|
@ -688,12 +688,15 @@ pub mod via_prelude {
|
|||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// // Built-in types
|
||||
/// let parser = clap::value_parser!(String);
|
||||
/// assert_eq!(format!("{:?}", parser), "ValueParser::string");
|
||||
/// let parser = clap::value_parser!(std::ffi::OsString);
|
||||
/// assert_eq!(format!("{:?}", parser), "ValueParser::os_string");
|
||||
/// let parser = clap::value_parser!(std::path::PathBuf);
|
||||
/// assert_eq!(format!("{:?}", parser), "ValueParser::path_buf");
|
||||
///
|
||||
/// // FromStr types
|
||||
/// let parser = clap::value_parser!(usize);
|
||||
/// assert_eq!(format!("{:?}", parser), "ValueParser::other(usize)");
|
||||
/// ```
|
||||
|
@ -707,24 +710,29 @@ macro_rules! value_parser {
|
|||
}
|
||||
|
||||
mod private {
|
||||
use super::*;
|
||||
|
||||
pub trait AnyValueParserSealed {}
|
||||
impl<T, P> AnyValueParserSealed for P
|
||||
where
|
||||
T: std::any::Any + Send + Sync + 'static,
|
||||
P: super::TypedValueParser<Value = T>,
|
||||
P: TypedValueParser<Value = T>,
|
||||
{
|
||||
}
|
||||
|
||||
pub trait ValueParserViaSelfSealed {}
|
||||
impl<P: Into<ValueParser>> ValueParserViaSelfSealed for &&&AutoValueParser<P> {}
|
||||
|
||||
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 &&AutoValueParser<String> {}
|
||||
impl ValueParserViaBuiltInSealed for &&AutoValueParser<std::ffi::OsString> {}
|
||||
impl ValueParserViaBuiltInSealed for &&AutoValueParser<std::path::PathBuf> {}
|
||||
|
||||
pub trait ValueParserViaArgEnumSealed {}
|
||||
impl<E: crate::ArgEnum> ValueParserViaArgEnumSealed for &super::AutoValueParser<E> {}
|
||||
impl<E: crate::ArgEnum> ValueParserViaArgEnumSealed for &AutoValueParser<E> {}
|
||||
|
||||
pub trait ValueParserViaFromStrSealed {}
|
||||
impl<FromStr> ValueParserViaFromStrSealed for super::AutoValueParser<FromStr>
|
||||
impl<FromStr> ValueParserViaFromStrSealed for AutoValueParser<FromStr>
|
||||
where
|
||||
FromStr: std::str::FromStr + std::any::Any + Send + Sync + 'static,
|
||||
<FromStr as std::str::FromStr>::Err:
|
||||
|
|
Loading…
Reference in a new issue