From a70f7203a46d471345128832987017612d8e4585 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Thu, 23 Jan 2020 14:40:43 -0800 Subject: macros: add pin! macro (#2163) Used for stack pinning and based on `pin_mut!` from the pin-util crate. Pinning is used often when working with stream operators and the select! macro. Given the small size of `pin!` it makes more sense to include a version than re-export one from a separate crate or require the user to depend on `pin-util` themselves. --- tests-integration/tests/macros_pin.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests-integration/tests/macros_pin.rs (limited to 'tests-integration') diff --git a/tests-integration/tests/macros_pin.rs b/tests-integration/tests/macros_pin.rs new file mode 100644 index 00000000..37d8f70f --- /dev/null +++ b/tests-integration/tests/macros_pin.rs @@ -0,0 +1,12 @@ +use futures::executor::block_on; + +async fn my_async_fn() {} + +#[test] +fn pin() { + block_on(async { + let future = my_async_fn(); + tokio::pin!(future); + (&mut future).await + }); +} -- cgit v1.2.3