Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow in-place unwrapping of future::Ready #2055

Merged
merged 2 commits into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# 0.3.2 - 2020-??-??
* Added `into_inner` method for `future::Ready` (#2055)

# 0.3.1 - 2019-11-7
* Fix signature of `LocalSpawn` trait (breaking change -- see #1959)

# 0.3.0 - 2019-11-5
* Stable release along with stable async/await!
* Added async/await to default features (#1953)
* Changed `Spawn` trait and `FuturesUnordered::push` to take `&self` (#1950)
* Moved `Spawn` and `FutureObj` out of `futures-core` and into `futures-task (#1925)
* Moved `Spawn` and `FutureObj` out of `futures-core` and into `futures-task` (#1925)
* Changed case convention for feature names (#1937)
* Added `executor` feature (#1949)
* Moved `copy_into`/`copy_buf_into` (#1948)
Expand Down
10 changes: 9 additions & 1 deletion futures-util/src/future/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ use futures_core::task::{Context, Poll};
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Ready<T>(Option<T>);

impl<T> Ready<T> {
/// Unwraps the value from this immediately ready future.
#[inline]
pub fn into_inner(mut self) -> T {
self.0.take().unwrap()
}
}

impl<T> Unpin for Ready<T> {}

impl<T> FusedFuture for Ready<T> {
Expand All @@ -24,7 +32,7 @@ impl<T> Future for Ready<T> {
}
}

/// Create a future that is immediately ready with a value.
/// Creates a future that is immediately ready with a value.
///
/// # Examples
///
Expand Down