diff options
-rw-r--r-- | src/arg_util.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/arg_util.rs b/src/arg_util.rs index 56f8758..b96f653 100644 --- a/src/arg_util.rs +++ b/src/arg_util.rs @@ -107,14 +107,23 @@ macro_rules! enum_int { } impl ::std::str::FromStr for $name { - type Err = (); + type Err = ::std::string::String; fn from_str(s: &str) -> ::std::result::Result<Self, Self::Err> { match s { $( $str => Ok($name::$var), )* - _ => Err(()), + _ => Err( + format!( + "expected one of {}", + $name::all_variants() + .iter() + .map(::std::convert::AsRef::as_ref) + .collect::<::std::vec::Vec<_>>() + .join(", "), + ) + ) } } } |