feat(derive): Accept Box/Arc wrapped types

This commit is contained in:
Ed Page 2023-07-05 09:53:41 -05:00
parent 7353b2be34
commit f043f57559

View file

@ -2215,6 +2215,28 @@ impl ValueParserFactory for u64 {
RangedU64ValueParser::new()
}
}
impl<T> ValueParserFactory for Box<T>
where
T: ValueParserFactory,
<T as ValueParserFactory>::Parser: TypedValueParser<Value = T>,
T: Send + Sync + Clone,
{
type Parser = MapValueParser<<T as ValueParserFactory>::Parser, fn(T) -> Box<T>>;
fn value_parser() -> Self::Parser {
T::value_parser().map(Box::new)
}
}
impl<T> ValueParserFactory for std::sync::Arc<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::sync::Arc<T>>;
fn value_parser() -> Self::Parser {
T::value_parser().map(std::sync::Arc::new)
}
}
#[doc(hidden)]
#[derive(Debug)]