Skip to content

Commit

Permalink
Match against an optional single trailing colon
Browse files Browse the repository at this point in the history
Currently we allow multiple trailing colons when matching within the
`check_format_non_negative` macro. We can be more restrictive with no
loss of usability.

Use `$(;)?` instead of `$(;)*` to match against 0 or 1 semi-colons
instead of 0 or more.
  • Loading branch information
tcharding committed May 26, 2022
1 parent 324fa0f commit 88ce8fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util/amount.rs
Expand Up @@ -1640,7 +1640,7 @@ mod tests {

// Creates individual test functions to make it easier to find which check failed.
macro_rules! check_format_non_negative {
($denom:ident; $($test_name:ident, $val:expr, $format_string:expr, $expected:expr);* $(;)*) => {
($denom:ident; $($test_name:ident, $val:expr, $format_string:expr, $expected:expr);* $(;)?) => {
$(
#[test]
fn $test_name() {
Expand All @@ -1652,7 +1652,7 @@ mod tests {
}

macro_rules! check_format_non_negative_show_denom {
($denom:ident, $denom_suffix:expr; $($test_name:ident, $val:expr, $format_string:expr, $expected:expr);* $(;)*) => {
($denom:ident, $denom_suffix:expr; $($test_name:ident, $val:expr, $format_string:expr, $expected:expr);* $(;)?) => {
$(
#[test]
fn $test_name() {
Expand Down

0 comments on commit 88ce8fe

Please sign in to comment.