We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I found something wrong on this page:
https://fasterthanli.me/articles/pin-and-suffering#position=31.0
Here's what it is:
this code doesn't work
use tokio::time::Sleep; struct MyFuture { sleep: Sleep, } impl MyFuture { fn new() -> Self { Self { sleep: tokio::time::sleep(Duration::from_secs(1)), } } } impl Future for MyFuture { type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { println!("MyFuture::poll()"); self.sleep.poll(cx) } }
Here you can find docs how it should be implemented: https://docs.rs/tokio/latest/tokio/time/struct.Sleep.html
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::time::Sleep; struct HasSleep { sleep: Pin<Box<Sleep>>, } impl Future for HasSleep { type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { self.sleep.as_mut().poll(cx) } }
The text was updated successfully, but these errors were encountered:
Oh, sorry. I just should've read it further. Close it please.
Sorry, something went wrong.
No branches or pull requests
I found something wrong on this page:
https://fasterthanli.me/articles/pin-and-suffering#position=31.0
Here's what it is:
this code doesn't work
Here you can find docs how it should be implemented:
https://docs.rs/tokio/latest/tokio/time/struct.Sleep.html
The text was updated successfully, but these errors were encountered: