Produce `None` instead of empty `meta` string
@@ -245,7 +245,7 @@ fn derive_options_struct(ast: &DeriveInput, fields: &[Field]) -> TokenStream {
if action.takes_arg() {
if opts.meta.is_none() {
- opts.meta = Some(make_meta(ident.as_ref(), action));
+ opts.meta = make_meta(ident.as_ref(), action);
}
} else if opts.meta.is_some() {
panic!("`meta` value is invalid for option `{}`", ident.as_ref());
@@ -908,13 +908,13 @@ fn valid_short_name(ch: char, names: &[char]) {
}
}
-fn make_meta(name: &str, action: Action) -> String {
+fn make_meta(name: &str, action: Action) -> Option<String> {
use std::fmt::Write;
let tuple_len = action.tuple_len();
if tuple_len == Some(0) {
- return String::new();
+ return None;
}
let mut name = name.replace('_', "-").to_uppercase();
@@ -933,7 +933,7 @@ fn make_meta(name: &str, action: Action) -> String {
}
}
- name
+ Some(name)
}
fn make_usage(opts: &[Opt]) -> String {
