Skip to content

Commit c5f4c95

Browse files
committed
address comments
Signed-off-by: tison <[email protected]>
1 parent 6d7ea3e commit c5f4c95

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

futures-util/src/future/future/mod.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -111,36 +111,6 @@ mod shared;
111111
#[cfg(any(feature = "std", all(feature = "alloc", feature = "spin")))]
112112
pub use self::shared::{Shared, WeakShared};
113113

114-
/// Pins a value on the stack.
115-
///
116-
/// **Note:** Since Rust 1.68, this macro is soft-deprecated in favor of
117-
/// [`pin!`](https://doc.rust-lang.org/std/pin/macro.pin.html) macro
118-
/// in the standard library.
119-
///
120-
/// # Example
121-
///
122-
/// ```rust
123-
/// # use futures_util::pin_mut;
124-
/// # use core::pin::Pin;
125-
/// # struct Foo {}
126-
/// let foo = Foo { /* ... */ };
127-
/// pin_mut!(foo);
128-
/// let _: Pin<&mut Foo> = foo;
129-
/// ```
130-
#[macro_export]
131-
macro_rules! pin_mut {
132-
($($x:ident),* $(,)?) => { $(
133-
// Move the value to ensure that it is owned
134-
let mut $x = $x;
135-
// Shadow the original binding so that it can't be directly accessed
136-
// ever again.
137-
#[allow(unused_mut)]
138-
let mut $x = unsafe {
139-
::core::pin::Pin::new_unchecked(&mut $x)
140-
};
141-
)* }
142-
}
143-
144114
impl<T: ?Sized> FutureExt for T where T: Future {}
145115

146116
/// An extension trait for `Future`s that provides a variety of convenient

futures-util/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,4 @@ mod abortable;
328328

329329
mod fns;
330330
mod unfold_state;
331+
mod macros;

futures-util/src/macros.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// Pins a value on the stack.
2+
///
3+
/// Can safely pin values that are not `Unpin` by taking ownership.
4+
///
5+
/// **Note:** Since Rust 1.68, this macro is soft-deprecated in favor of
6+
/// [`pin!`](https://doc.rust-lang.org/std/pin/macro.pin.html) macro
7+
/// in the standard library.
8+
///
9+
/// # Example
10+
///
11+
/// ```rust
12+
/// # use futures_util::pin_mut;
13+
/// # use core::pin::Pin;
14+
/// # struct Foo {}
15+
/// let foo = Foo { /* ... */ };
16+
/// pin_mut!(foo);
17+
/// let _: Pin<&mut Foo> = foo;
18+
/// ```
19+
#[macro_export]
20+
macro_rules! pin_mut {
21+
($($x:ident),* $(,)?) => { $(
22+
// Move the value to ensure that it is owned
23+
let mut $x = $x;
24+
// Shadow the original binding so that it can't be directly accessed
25+
// ever again.
26+
#[allow(unused_mut)]
27+
let mut $x = unsafe {
28+
::core::pin::Pin::new_unchecked(&mut $x)
29+
};
30+
)* }
31+
}

0 commit comments

Comments
 (0)