]> git.lizzy.rs Git - rust.git/commitdiff
Add trailing comma support to matches macro
authorChristian Duerr <contact@christianduerr.com>
Tue, 28 Jul 2020 16:42:13 +0000 (18:42 +0200)
committerChristian Duerr <contact@christianduerr.com>
Tue, 28 Jul 2020 16:42:13 +0000 (18:42 +0200)
library/core/src/macros/mod.rs

index 3b9057b7e8377911feec5d30b98e163a787d0fab..c92ca22509afc9cc90604ed44fff66e1c129a3e1 100644 (file)
@@ -255,7 +255,7 @@ macro_rules! debug_assert_ne {
 #[macro_export]
 #[stable(feature = "matches_macro", since = "1.42.0")]
 macro_rules! matches {
-    ($expression:expr, $( $pattern:pat )|+ $( if $guard: expr )?) => {
+    ($expression:expr, $( $pattern:pat )|+ $( if $guard: expr )? $(,)?) => {
         match $expression {
             $( $pattern )|+ $( if $guard )? => true,
             _ => false