From 5f59e87f26eae9bb716f161fe40fe1fc0771e30c Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 14 Jul 2019 22:16:09 +0900 Subject: [PATCH] Support trailing commas in pin_mut! macro --- src/stack_pin.rs | 2 +- tests/stack_pin.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/stack_pin.rs b/src/stack_pin.rs index 997a5b9..f8ac524 100644 --- a/src/stack_pin.rs +++ b/src/stack_pin.rs @@ -10,7 +10,7 @@ /// ``` #[macro_export] macro_rules! pin_mut { - ($($x:ident),*) => { $( + ($($x:ident),* $(,)?) => { $( // Move the value to ensure that it is owned let mut $x = $x; // Shadow the original binding so that it can't be directly accessed diff --git a/tests/stack_pin.rs b/tests/stack_pin.rs index 0708a7d..ce83491 100644 --- a/tests/stack_pin.rs +++ b/tests/stack_pin.rs @@ -7,4 +7,13 @@ fn stack_pin() { let foo = Foo {}; pin_mut!(foo); let _: Pin<&mut Foo> = foo; + + let bar = Foo {}; + let baz = Foo {}; + pin_mut!( + bar, + baz, + ); + let _: Pin<&mut Foo> = bar; + let _: Pin<&mut Foo> = baz; }