From e63760e461fdac8b23ac04cf8e58e9055bffa226 Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Sun, 17 Oct 2021 16:58:58 +0100 Subject: [PATCH] Allow possible_values to take string vector reference Makes it more backward compatible and flexible --- src/build/arg/arg_value.rs | 6 ++++++ tests/require.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/build/arg/arg_value.rs b/src/build/arg/arg_value.rs index 7fbb5dbe..88757716 100644 --- a/src/build/arg/arg_value.rs +++ b/src/build/arg/arg_value.rs @@ -38,6 +38,12 @@ impl<'help> From<&'help str> for ArgValue<'help> { } } +impl<'help> From<&'help &'help str> for ArgValue<'help> { + fn from(s: &'help &'help str) -> Self { + Self::new(s) + } +} + /// Getters impl<'help> ArgValue<'help> { /// Get the name of the argument value diff --git a/tests/require.rs b/tests/require.rs index 79442116..5fb2fb08 100644 --- a/tests/require.rs +++ b/tests/require.rs @@ -711,7 +711,7 @@ fn required_if_val_present_fail_error_output() { Arg::new("target") .takes_value(true) .required(true) - .possible_values(["file", "stdout"]) + .possible_values(&["file", "stdout"]) .long("target"), ) .arg(