mirror of
https://github.com/openharmony/third_party_rust_pin-utils.git
synced 2026-06-30 21:47:59 -04:00
Support trailing commas in pin_mut! macro
This commit is contained in:
committed by
Taylor Cramer
parent
0a35ad97b1
commit
5f387f8057
+1
-1
@@ -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,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user