Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support trailing commas in pin_mut! macro #23

Merged
merged 1 commit into from Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -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;
}