-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new example to reprodue a rust issue
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
- Loading branch information
1 parent
8f818b7
commit 37bcbde
Showing
2 changed files
with
38 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "lifetime_issue" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
rio_rt = { path = "../../rt" } |
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,31 @@ | ||
use rio_rt::runitime as rio; | ||
use std::future::Future; | ||
use std::io; | ||
use std::pin::Pin; | ||
use std::task::Context; | ||
use std::task::Poll; | ||
|
||
pub struct AdaptorFuture<F> { | ||
inner: F, | ||
} | ||
|
||
impl<F, T> Future for AdaptorFuture<F> | ||
where | ||
F: Future<Output = T>, | ||
{ | ||
type Output = Result<T, io::Error>; | ||
|
||
fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> { | ||
panic!() | ||
} | ||
} | ||
|
||
fn call<R>(req: R) -> AdaptorFuture<R> { | ||
AdaptorFuture { | ||
inner: req, | ||
} | ||
} | ||
|
||
fn main() { | ||
rio::block_on(async { call(1); }) | ||
} |