Skip to content

Commit c5c976d

Browse files
committed
Revert "Replace the Future impl for Option with IntoFuture"
This reverts commit db77995.
1 parent 5d1adc2 commit c5c976d

File tree

3 files changed

+9
-29
lines changed

3 files changed

+9
-29
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "futures"
3-
version = "0.1.19"
3+
version = "0.1.20"
44
authors = ["Alex Crichton <[email protected]>"]
55
license = "MIT/Apache-2.0"
66
readme = "README.md"

src/future/option.rs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
11
//! Definition of the `Option` (optional step) combinator
22
3-
use {Future, IntoFuture, Poll, Async};
4-
use core::option;
3+
use {Future, Poll, Async};
54

6-
/// An optional future.
7-
///
8-
/// Created by `Option::into_future`.
9-
#[derive(Debug, Clone)]
10-
#[must_use = "futures do nothing unless polled"]
11-
pub struct Option<F> {
12-
inner: option::Option<F>,
13-
}
14-
15-
impl<F> IntoFuture for option::Option<F> where F: Future {
16-
type Future = Option<F>;
17-
type Item = option::Option<F::Item>;
18-
type Error = F::Error;
19-
20-
fn into_future(self) -> Self::Future {
21-
Option { inner: self }
22-
}
23-
}
24-
25-
impl<F> Future for Option<F> where F: Future {
26-
type Item = option::Option<F::Item>;
27-
type Error = F::Error;
5+
impl<F, T, E> Future for Option<F> where F: Future<Item=T, Error=E> {
6+
type Item = Option<T>;
7+
type Error = E;
288

29-
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
30-
match self.inner {
9+
fn poll(&mut self) -> Poll<Option<T>, E> {
10+
match *self {
3111
None => Ok(Async::Ready(None)),
3212
Some(ref mut x) => x.poll().map(|x| x.map(Some)),
3313
}

tests/all.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ fn select2() {
356356

357357
#[test]
358358
fn option() {
359-
assert_eq!(Ok(Some(())), Some(ok::<(), ()>(())).into_future().wait());
360-
assert_eq!(Ok(None), None::<FutureResult<(), ()>>.into_future().wait());
359+
assert_eq!(Ok(Some(())), Some(ok::<(), ()>(())).wait());
360+
assert_eq!(Ok(None), <Option<FutureResult<(), ()>> as Future>::wait(None));
361361
}
362362

363363
#[test]

0 commit comments

Comments
 (0)