diff --git a/clap_builder/src/builder/value_parser.rs b/clap_builder/src/builder/value_parser.rs index 2e43d98f652..b1540e08a10 100644 --- a/clap_builder/src/builder/value_parser.rs +++ b/clap_builder/src/builder/value_parser.rs @@ -2137,18 +2137,38 @@ impl ValueParserFactory for String { ValueParser::string() // Default `clap_derive` to optimized implementation } } +impl ValueParserFactory for Box { + type Parser = MapValueParser Box>; + fn value_parser() -> Self::Parser { + StringValueParser::new().map(String::into_boxed_str) + } +} impl ValueParserFactory for std::ffi::OsString { type Parser = ValueParser; fn value_parser() -> Self::Parser { ValueParser::os_string() // Default `clap_derive` to optimized implementation } } +impl ValueParserFactory for Box { + type Parser = + MapValueParser Box>; + fn value_parser() -> Self::Parser { + OsStringValueParser::new().map(std::ffi::OsString::into_boxed_os_str) + } +} impl ValueParserFactory for std::path::PathBuf { type Parser = ValueParser; fn value_parser() -> Self::Parser { ValueParser::path_buf() // Default `clap_derive` to optimized implementation } } +impl ValueParserFactory for Box { + type Parser = + MapValueParser Box>; + fn value_parser() -> Self::Parser { + PathBufValueParser::new().map(std::path::PathBuf::into_boxed_path) + } +} impl ValueParserFactory for bool { type Parser = ValueParser; fn value_parser() -> Self::Parser {