1/// Pins a value on the stack.
2///
3/// # Example
4///
5/// ```rust
6/// # use pin_utils::pin_mut;
7/// # use core::pin::Pin;
8/// # struct Foo {}
9/// let foo = Foo { /* ... */ };
10/// pin_mut!(foo);
11/// let _: Pin<&mut Foo> = foo;
12/// ```
13#[macro_export]
14macro_rules! pin_mut {
15 ($($x:ident),* $(,)?) => { $(
16 // Move the value to ensure that it is owned
17 let mut $x = $x;
18 // Shadow the original binding so that it can't be directly accessed
19 // ever again.
20 #[allow(unused_mut)]
21 let mut $x = unsafe {
22 $crate::core_reexport::pin::Pin::new_unchecked(&mut $x)
23 };
24 )* }
25}
26