diff options
| author | tinaun <tinagma@gmail.com> | 2018-06-08 16:45:27 -0400 |
|---|---|---|
| committer | tinaun <tinagma@gmail.com> | 2018-06-08 17:56:59 -0400 |
| commit | 6e5c18e8dc94a679126d276884a3ad4b9a3e0934 (patch) | |
| tree | c7b916bf935b8d4bf1d7d9646b13b71e76157006 /src/libstd | |
| parent | 1b4c921103ff4ae225f2d84a8b13f1616dcb538e (diff) | |
| download | rust-6e5c18e8dc94a679126d276884a3ad4b9a3e0934.tar.gz rust-6e5c18e8dc94a679126d276884a3ad4b9a3e0934.zip | |
add a few blanket future impls to std
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/lib.rs | 1 | ||||
| -rw-r--r-- | src/libstd/panic.rs | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 7bbc99b83be..bb23fe5fa91 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -239,6 +239,7 @@ #![feature(allow_internal_unsafe)] #![feature(allow_internal_unstable)] #![feature(align_offset)] +#![feature(arbitrary_self_types)] #![feature(array_error_internals)] #![feature(ascii_ctype)] #![feature(asm)] diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 229034eb779..b70de73991f 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -15,11 +15,14 @@ use any::Any; use cell::UnsafeCell; use fmt; +use future::Future; +use mem::PinMut; use ops::{Deref, DerefMut}; use panicking; use ptr::{Unique, NonNull}; use rc::Rc; use sync::{Arc, Mutex, RwLock, atomic}; +use task::{self, Poll}; use thread::Result; #[stable(feature = "panic_hooks", since = "1.10.0")] @@ -315,6 +318,21 @@ impl<T: fmt::Debug> fmt::Debug for AssertUnwindSafe<T> { } } +#[unstable(feature = "futures_api", issue = "50547")] +impl<'a, F: Future> Future for AssertUnwindSafe<F> { + type Output = F::Output; + + fn poll(mut self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output> { + unsafe { + let pinned_field = PinMut::new_unchecked( + &mut PinMut::get_mut(self.reborrow()).0 + ); + + pinned_field.poll(cx) + } + } +} + /// Invokes a closure, capturing the cause of an unwinding panic if one occurs. /// /// This function will return `Ok` with the closure's result if the closure |
