From b35fe5301afb167ea31410bde49f4a3220eac1b1 Mon Sep 17 00:00:00 2001 From: Drake Tetreault Date: Tue, 10 Dec 2019 20:53:57 -0800 Subject: [PATCH] Ran cargo fmt. --- src/future.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/future.rs b/src/future.rs index 9068689..5b24e2e 100644 --- a/src/future.rs +++ b/src/future.rs @@ -2,11 +2,11 @@ use core::cell::Cell; use core::marker::Unpin; -use core::pin::Pin; +use core::ops::{Deref, Drop, Generator, GeneratorState}; use core::option::Option; +use core::pin::Pin; use core::ptr::NonNull; use core::task::{Context, Poll}; -use core::ops::{Deref, Drop, Generator, GeneratorState}; #[doc(inline)] pub use core::future::*; @@ -75,12 +75,10 @@ impl Drop for SetOnDrop { /// Sets the thread-local task context used by async/await futures. pub fn set_task_context(cx: &mut Context<'_>, f: F) -> R where - F: FnOnce() -> R + F: FnOnce() -> R, { // transmute the context's lifetime to 'static so we can store it. - let cx = unsafe { - core::mem::transmute::<&mut Context<'_>, &mut Context<'static>>(cx) - }; + let cx = unsafe { core::mem::transmute::<&mut Context<'_>, &mut Context<'static>>(cx) }; let old_cx = TLS_CX.replace(Some(NonNull::from(cx))); let _reset = SetOnDrop(old_cx); f() @@ -95,7 +93,7 @@ where /// retrieved by a surrounding call to get_task_context. pub fn get_task_context(f: F) -> R where - F: FnOnce(&mut Context<'_>) -> R + F: FnOnce(&mut Context<'_>) -> R, { // Clear the entry so that nested `get_task_waker` calls // will fail or set their own value. @@ -104,7 +102,8 @@ where let mut cx_ptr = cx_ptr.expect( "TLS Context not set. This is a rustc bug. \ - Please file an issue on https://github.com/rust-lang/rust."); + Please file an issue on https://github.com/rust-lang/rust.", + ); // Safety: we've ensured exclusive access to the context by // removing the pointer from TLS, only to be replaced once @@ -119,7 +118,7 @@ where /// Polls a future in the current thread-local task waker. pub fn poll_with_tls_context(f: Pin<&mut F>) -> Poll where - F: Future + F: Future, { get_task_context(|cx| F::poll(f, cx)) }