Skip to content

Commit

Permalink
feat(builder): Add ValueParserFactory for Saturating<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Feb 24, 2025
1 parent 8a1d59b commit 536e29f
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 536e29f

Please sign in to comment.