-
Notifications
You must be signed in to change notification settings - Fork 341
Add future::delay #349
New issue
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
Add future::delay #349
Conversation
ea635fe
to
358d2bc
Compare
src/future/future.rs
Outdated
/// ``` | ||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] | ||
#[cfg(any(feature = "unstable", feature = "docs"))] | ||
fn delay(self, dur: Duration) -> DelayFuture<Self> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should obfuscate the type here, as we're awaiting async fn
in traits to be released. Look at the ret!
macro in the stream module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this? 53fa132
I don't know why I'm doing this, can you give me an explanation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a concrete type is returned from a trait, people might start relying on it, making this a compatibility hazard towards a future impl Future...
version (which is effectively coming with proper async traits).
I fixed it and rebase master branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. One minor nit to the documentation.
src/future/future.rs
Outdated
@@ -99,6 +107,28 @@ extension_trait! { | |||
} | |||
|
|||
pub trait FutureExt: std::future::Future { | |||
/// Creates a future that is delayed before it starts yielding items. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the implementation, I'm not sure if this documentation is correct.
To my reading, it delays execution of the future for the time time given. It will never be polled before the delay resolves. (which might or might not be what you want)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. I'm not fluent in English, so it might still be wrong ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Thanks so much!
Thanks! |
close: #341