Implement Ready::into_inner()

This commit is contained in:
dAxpeDDa 2022-08-30 11:21:07 +02:00
parent a0d07093f8
commit 5ed1787413
No known key found for this signature in database
GPG Key ID: 43D62A3EA388E46F

View File

@ -24,6 +24,30 @@ fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
}
}
impl<T> Ready<T> {
/// Consumes the `Ready`, returning the wrapped value.
///
/// # Panics
///
/// Will panic if this [`Ready`] was already polled to completion.
///
/// # Examples
///
/// ```
/// #![feature(ready_into_inner)]
/// use std::future;
///
/// let a = future::ready(1);
/// assert_eq!(a.into_inner(), 1);
/// ```
#[unstable(feature = "ready_into_inner", issue = "101196")]
#[must_use]
#[inline]
pub fn into_inner(self) -> T {
self.0.expect("Called `into_inner()` on `Ready` after completion")
}
}
/// Creates a future that is immediately ready with a value.
///
/// Futures created through this function are functionally similar to those