-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
208dd20
commit 2b4b416
Showing
4 changed files
with
130 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// run-pass | ||
// aux-build: issue-72470-lib.rs | ||
// edition:2021 | ||
extern crate issue_72470_lib; | ||
use std::{future::{Future, IntoFuture}, pin::Pin}; | ||
|
||
struct AwaitMe; | ||
|
||
impl IntoFuture for &AwaitMe { | ||
type Output = i32; | ||
type IntoFuture = Pin<Box<dyn Future<Output = i32>>>; | ||
|
||
fn into_future(self) -> Self::IntoFuture { | ||
Box::pin(me()) | ||
} | ||
} | ||
|
||
async fn me() -> i32 { | ||
41 | ||
} | ||
|
||
async fn run() { | ||
assert_eq!(AwaitMe.await, 41); | ||
} | ||
|
||
struct AwaitMeToo; | ||
|
||
impl IntoFuture for &mut AwaitMeToo { | ||
type Output = i32; | ||
type IntoFuture = Pin<Box<dyn Future<Output = i32>>>; | ||
|
||
fn into_future(self) -> Self::IntoFuture { | ||
Box::pin(me()) | ||
} | ||
} | ||
|
||
async fn run_too() { | ||
assert_eq!(AwaitMeToo.await, 41); | ||
} | ||
|
||
fn main() { | ||
issue_72470_lib::run(run()); | ||
issue_72470_lib::run(run_too()); | ||
} |