Skip to content

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

Merged
merged 10 commits into from
Oct 29, 2019
Merged

Add future::delay #349

merged 10 commits into from
Oct 29, 2019

Conversation

k-nasa
Copy link
Member

@k-nasa k-nasa commented Oct 16, 2019

close: #341

/// ```
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[cfg(any(feature = "unstable", feature = "docs"))]
fn delay(self, dur: Duration) -> DelayFuture<Self>
Copy link
Contributor

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

Copy link
Member Author

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?

Copy link
Collaborator

@skade skade Oct 28, 2019

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).

@k-nasa k-nasa requested a review from yoshuawuyts October 17, 2019 07:42
@k-nasa
Copy link
Member Author

k-nasa commented Oct 24, 2019

I fixed it and rebase master branch.
Can you review again?

Copy link
Collaborator

@skade skade left a 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.

@@ -99,6 +107,28 @@ extension_trait! {
}

pub trait FutureExt: std::future::Future {
/// Creates a future that is delayed before it starts yielding items.
Copy link
Collaborator

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)

Copy link
Member Author

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 ...

Copy link
Contributor

@yoshuawuyts yoshuawuyts left a 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!

@yoshuawuyts yoshuawuyts added the enhancement New feature or request label Oct 28, 2019
@yoshuawuyts yoshuawuyts merged commit 206bedf into async-rs:master Oct 29, 2019
@k-nasa k-nasa deleted the add_future_delay branch October 29, 2019 01:25
@k-nasa
Copy link
Member Author

k-nasa commented Oct 29, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Future::delay
3 participants