diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-03-11 20:29:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-11 20:29:45 +0100 |
| commit | fedf70acb1e8a51c36a970bf20aa4e6febf815f9 (patch) | |
| tree | dca024c85dac6655a620d931fd38ff7d58f54960 | |
| parent | 86376e3aeae46f31ba14e82835ed27a063fb31e5 (diff) | |
| parent | 3f2cb6eba1ce2dfdc4db3743f29363396942ce28 (diff) | |
| download | rust-fedf70acb1e8a51c36a970bf20aa4e6febf815f9.tar.gz rust-fedf70acb1e8a51c36a970bf20aa4e6febf815f9.zip | |
Rollup merge of #94818 - yoshuawuyts:into-future-associated-type, r=joshtriplett
Rename `IntoFuture::Future` to `IntoFuture::IntoFuture`
Ref: https://github.com/rust-lang/rust/issues/67644#issuecomment-1051401459
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`
| -rw-r--r-- | library/core/src/future/into_future.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/async-await/await-into-future.rs | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/library/core/src/future/into_future.rs b/library/core/src/future/into_future.rs index 0912f8675fa..8014dacdd98 100644 --- a/library/core/src/future/into_future.rs +++ b/library/core/src/future/into_future.rs @@ -9,20 +9,20 @@ pub trait IntoFuture { /// Which kind of future are we turning this into? #[unstable(feature = "into_future", issue = "67644")] - type Future: Future<Output = Self::Output>; + type IntoFuture: Future<Output = Self::Output>; /// Creates a future from a value. #[unstable(feature = "into_future", issue = "67644")] #[lang = "into_future"] - fn into_future(self) -> Self::Future; + fn into_future(self) -> Self::IntoFuture; } #[unstable(feature = "into_future", issue = "67644")] impl<F: Future> IntoFuture for F { type Output = F::Output; - type Future = F; + type IntoFuture = F; - fn into_future(self) -> Self::Future { + fn into_future(self) -> Self::IntoFuture { self } } diff --git a/src/test/ui/async-await/await-into-future.rs b/src/test/ui/async-await/await-into-future.rs index b74b1684440..6e1b155e181 100644 --- a/src/test/ui/async-await/await-into-future.rs +++ b/src/test/ui/async-await/await-into-future.rs @@ -10,9 +10,9 @@ struct AwaitMe; impl IntoFuture for AwaitMe { type Output = i32; - type Future = Pin<Box<dyn Future<Output = i32>>>; + type IntoFuture = Pin<Box<dyn Future<Output = i32>>>; - fn into_future(self) -> Self::Future { + fn into_future(self) -> Self::IntoFuture { Box::pin(me()) } } |
