Skip to content

Commit

Permalink
refactor(assert): Make it easier to change id type
Browse files Browse the repository at this point in the history
Compared to `master` on `06_rustup`:
- build: 5.74us -> 6.21us
- parse: 7.57us -> 7.55us
- parse_sc: 7.60us -> 7.95us
  • Loading branch information
epage committed Aug 12, 2022
1 parent 426a7d2 commit 96f91ca
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/macros.rs
Expand Up @@ -204,7 +204,7 @@ macro_rules! arg_impl {

let mut arg = $arg;
let long = $crate::arg_impl! { @string $long };
if arg.get_id().is_empty() {
if arg.get_id() == "" {
arg = arg.id(long);
}
let action = $crate::ArgAction::SetTrue;
Expand All @@ -229,7 +229,7 @@ macro_rules! arg_impl {

let mut arg = $arg;
let long = $crate::arg_impl! { @string $long };
if arg.get_id().is_empty() {
if arg.get_id() == "" {
arg = arg.id(long);
}
let action = $crate::ArgAction::SetTrue;
Expand Down Expand Up @@ -299,7 +299,7 @@ macro_rules! arg_impl {
arg = arg.required(true);

let value_name = $crate::arg_impl! { @string $value_name };
if arg.get_id().is_empty() {
if arg.get_id() == "" {
arg = arg.id(value_name);
}
arg
Expand All @@ -326,7 +326,7 @@ macro_rules! arg_impl {
arg = arg.required(true);

let value_name = $crate::arg_impl! { @string $value_name };
if arg.get_id().is_empty() {
if arg.get_id() == "" {
arg = arg.id(value_name);
}
arg
Expand Down Expand Up @@ -357,7 +357,7 @@ macro_rules! arg_impl {
}

let value_name = $crate::arg_impl! { @string $value_name };
if arg.get_id().is_empty() {
if arg.get_id() == "" {
arg = arg.id(value_name);
}
arg
Expand Down Expand Up @@ -388,7 +388,7 @@ macro_rules! arg_impl {
}

let value_name = $crate::arg_impl! { @string $value_name };
if arg.get_id().is_empty() {
if arg.get_id() == "" {
arg = arg.id(value_name);
}
arg
Expand Down Expand Up @@ -536,7 +536,7 @@ macro_rules! arg {
let arg = $crate::arg_impl! {
@arg ($crate::Arg::default()) $($tail)+
};
debug_assert!(!arg.get_id().is_empty(), "Without a value or long flag, the `name:` prefix is required");
debug_assert_ne!(arg.get_id(), "", "Without a value or long flag, the `name:` prefix is required");
arg
}};
}
Expand Down

0 comments on commit 96f91ca

Please sign in to comment.