Support trailing commas in pin_mut! macro

This commit is contained in:
Taiki Endo
2019-07-14 22:16:09 +09:00
committed by Taylor Cramer
parent 0a35ad97b1
commit 5f387f8057
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -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
+9
View File
@@ -9,4 +9,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;
}