Match against an optional single trailing colon

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.
This commit is contained in:
Tobin C. Harding 2022-05-26 11:25:42 +10:00
parent 324fa0f7be
commit 88ce8fe923
1 changed files with 2 additions and 2 deletions

View File

@ -1640,7 +1640,7 @@ mod tests {
// Creates individual test functions to make it easier to find which check failed. // Creates individual test functions to make it easier to find which check failed.
macro_rules! check_format_non_negative { 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] #[test]
fn $test_name() { fn $test_name() {
@ -1652,7 +1652,7 @@ mod tests {
} }
macro_rules! check_format_non_negative_show_denom { 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] #[test]
fn $test_name() { fn $test_name() {