Skip to content

Commit

Permalink
Merge pull request #5926 from sorairolake/feature/value-parser-factor…
Browse files Browse the repository at this point in the history
…y-for-saturating

feat(builder): Add `ValueParserFactory` for `Saturating<T>`
  • Loading branch information
epage authored Feb 24, 2025
2 parents 13931a2 + 536e29f commit 233c316
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions clap_builder/src/builder/value_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2387,6 +2387,18 @@ impl ValueParserFactory for i64 {
RangedI64ValueParser::new()
}
}
impl<T> ValueParserFactory for std::num::Saturating<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::Saturating<T>>;
fn value_parser() -> Self::Parser {
T::value_parser().map(std::num::Saturating)
}
}
impl<T> ValueParserFactory for std::num::Wrapping<T>
where
T: ValueParserFactory,
Expand Down

0 comments on commit 233c316

Please sign in to comment.