Implement Ready::into_inner()
This commit is contained in:
parent
a0d07093f8
commit
5ed1787413
@ -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.
|
/// Creates a future that is immediately ready with a value.
|
||||||
///
|
///
|
||||||
/// Futures created through this function are functionally similar to those
|
/// Futures created through this function are functionally similar to those
|
||||||
|
Loading…
Reference in New Issue
Block a user