Skip to content

Commit 233c316

Browse files
authored
Merge pull request #5926 from sorairolake/feature/value-parser-factory-for-saturating
feat(builder): Add `ValueParserFactory` for `Saturating<T>`
2 parents 13931a2 + 536e29f commit 233c316

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

clap_builder/src/builder/value_parser.rs

+12
Original file line numberDiff line numberDiff line change
@@ -2387,6 +2387,18 @@ impl ValueParserFactory for i64 {
23872387
RangedI64ValueParser::new()
23882388
}
23892389
}
2390+
impl<T> ValueParserFactory for std::num::Saturating<T>
2391+
where
2392+
T: ValueParserFactory,
2393+
<T as ValueParserFactory>::Parser: TypedValueParser<Value = T>,
2394+
T: Send + Sync + Clone,
2395+
{
2396+
type Parser =
2397+
MapValueParser<<T as ValueParserFactory>::Parser, fn(T) -> std::num::Saturating<T>>;
2398+
fn value_parser() -> Self::Parser {
2399+
T::value_parser().map(std::num::Saturating)
2400+
}
2401+
}
23902402
impl<T> ValueParserFactory for std::num::Wrapping<T>
23912403
where
23922404
T: ValueParserFactory,

0 commit comments

Comments
 (0)