diff options
author | Carl Lerche <me@carllerche.com> | 2020-01-23 14:40:43 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-23 14:40:43 -0800 |
commit | a70f7203a46d471345128832987017612d8e4585 (patch) | |
tree | b73d40b54e0d627a7bfaa64ccacc87e238bd5164 /tests-integration | |
parent | 7079bcd60975f592e08fcd575991f6ae2a409a1f (diff) |
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.
Diffstat (limited to 'tests-integration')
-rw-r--r-- | tests-integration/tests/macros_pin.rs | 12 |
1 files changed, 12 insertions, 0 deletions
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 + }); +} |