Skip to content

Commit

Permalink
Support trailing commas in pin_mut! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e authored and cramertj committed Oct 16, 2019
1 parent 697a723 commit 72d3f9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/stack_pin.rs
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/stack_pin.rs
Expand Up @@ -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;
}

0 comments on commit 72d3f9c

Please sign in to comment.