Skip to content

Commit

Permalink
feat(derive): Accept num::Wrapping wrapped types
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 5, 2023
1 parent f043f57 commit 916c8d9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions clap_builder/src/builder/value_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,17 @@ impl ValueParserFactory for u64 {
RangedU64ValueParser::new()
}
}
impl<T> ValueParserFactory for std::num::Wrapping<T>
where
T: ValueParserFactory,
<T as ValueParserFactory>::Parser: TypedValueParser<Value = T>,
T: Send + Sync + Clone,
{
type Parser = MapValueParser<<T as ValueParserFactory>::Parser, fn(T) -> std::num::Wrapping<T>>;
fn value_parser() -> Self::Parser {
T::value_parser().map(std::num::Wrapping)
}
}
impl<T> ValueParserFactory for Box<T>
where
T: ValueParserFactory,
Expand Down

0 comments on commit 916c8d9

Please sign in to comment.