Skip to content

Simplify extension traits using a macro #241

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 4 commits into from Sep 27, 2019
Merged

Simplify extension traits using a macro #241

merged 4 commits into from Sep 27, 2019

Conversation

ghost
Copy link

@ghost ghost commented Sep 26, 2019

This PR would fix #235

Async methods in our extension traits are now written in the simpler -> impl Future<Output = T> [ConcreteFuture<Self>] style. At the same time, doc tests are used even when the docs feature is not enabled.

/// The type of items yielded by this stream.
type Item;

#[doc = r#"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to write docs in Stream in this style because the macro will otherwise exceed the recursion limit and dramatically slow compilation down. That is because each line starting with /// is a token itself, but with #[doc = "..."] we can put the whole docs for a function into a single token tree, meaning the macro makes progress faster - instead of consuming docs line by line it consumes them in a single bite.

@ghost ghost marked this pull request as ready for review September 26, 2019 18:32
@ghost ghost requested a review from yoshuawuyts September 26, 2019 18:33
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.

These are a lot of changes, but they look good. Thanks for doing this!

@yoshuawuyts
Copy link
Contributor

bors r+

bors bot added a commit that referenced this pull request Sep 27, 2019
241: Simplify extension traits using a macro r=yoshuawuyts a=stjepang

This PR would fix #235 

Async methods in our extension traits are now written in the simpler `-> impl Future<Output = T> [ConcreteFuture<Self>]` style. At the same time, doc tests are used even when the `docs` feature is not enabled.

Co-authored-by: Stjepan Glavina <[email protected]>
@bors
Copy link
Contributor

bors bot commented Sep 27, 2019

Build succeeded

  • continuous-integration/travis-ci/push

@bors bors bot merged commit 414fadd into async-rs:master Sep 27, 2019
@ghost ghost deleted the macro-extensions branch September 27, 2019 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stream doc tests are now disabled
1 participant