Skip to content

Commit fedf70a

Browse files
authored
Rollup merge of #94818 - yoshuawuyts:into-future-associated-type, r=joshtriplett
Rename `IntoFuture::Future` to `IntoFuture::IntoFuture` Ref: #67644 (comment) This renames `IntoFuture::Future` to `IntoFuture::IntoFuture`. This adds the `Into*` prefix to the associated type, similar to the [`IntoIterator::IntoIter`](https://doc.rust-lang.org/std/iter/trait.IntoIterator.html#associatedtype.IntoIter) associated type. It's my mistake we didn't do so in the first place. This fixes that and brings the two closer together. Thanks! ### References __`IntoIterator` trait def__ ```rust pub trait IntoIterator { type Item; type IntoIter: Iterator<Item = Self::Item>; fn into_iter(self) -> Self::IntoIter; } ``` __`IntoFuture` trait def__ ```rust pub trait IntoFuture { type Output; type IntoFuture: Future<Output = Self::Output>; // Prior to this PR: `type Future:` fn into_future(self) -> Self::IntoFuture; } ``` cc/ `@eholk` `@rust-lang/wg-async`
2 parents 86376e3 + 3f2cb6e commit fedf70a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

library/core/src/future/into_future.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ pub trait IntoFuture {
99

1010
/// Which kind of future are we turning this into?
1111
#[unstable(feature = "into_future", issue = "67644")]
12-
type Future: Future<Output = Self::Output>;
12+
type IntoFuture: Future<Output = Self::Output>;
1313

1414
/// Creates a future from a value.
1515
#[unstable(feature = "into_future", issue = "67644")]
1616
#[lang = "into_future"]
17-
fn into_future(self) -> Self::Future;
17+
fn into_future(self) -> Self::IntoFuture;
1818
}
1919

2020
#[unstable(feature = "into_future", issue = "67644")]
2121
impl<F: Future> IntoFuture for F {
2222
type Output = F::Output;
23-
type Future = F;
23+
type IntoFuture = F;
2424

25-
fn into_future(self) -> Self::Future {
25+
fn into_future(self) -> Self::IntoFuture {
2626
self
2727
}
2828
}

src/test/ui/async-await/await-into-future.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ struct AwaitMe;
1010

1111
impl IntoFuture for AwaitMe {
1212
type Output = i32;
13-
type Future = Pin<Box<dyn Future<Output = i32>>>;
13+
type IntoFuture = Pin<Box<dyn Future<Output = i32>>>;
1414

15-
fn into_future(self) -> Self::Future {
15+
fn into_future(self) -> Self::IntoFuture {
1616
Box::pin(me())
1717
}
1818
}

0 commit comments

Comments
 (0)