-
Notifications
You must be signed in to change notification settings - Fork 35
Add for_await to process streams using a for loop #2
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
Conversation
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.
Blocked on #1
@@ -20,7 +20,7 @@ repository = "https://github.com/tokio-rs/async-stream" | |||
readme = "README.md" | |||
|
|||
[dependencies] | |||
async-stream-impl = { version = "0.1.0" } | |||
async-stream-impl = { version = "0.1.0", path = "../async-stream-impl" } |
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 must be revert before merging.
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.
It's fine to keep the path in here IMO.
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.
LGTM 👍 some thoughts inline.
@@ -98,6 +98,42 @@ impl VisitMut for Scrub { | |||
syn::visit_mut::visit_expr_mut(self, i); | |||
self.is_xforming = prev; | |||
} | |||
syn::Expr::ForLoop(expr) => { | |||
syn::visit_mut::visit_expr_for_loop_mut(self, expr); | |||
// TODO: Should we allow other attributes? |
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.
What about just #[await]
?
Also, since this is a macro anyway, we could potentially get more aggressive and transform:
for await foo in my_stream {
}
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.
What about just
#[await]
?
Sounds good to me.
for await foo in my_stream { }
I think syn doesn't support this syntax yet.
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.
(By the way, that TODO comment is about the current implementation confirming that the number of attributes is exactly one.)
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.
syn
doesn't support it... but it may not be too hard to impl. You would have to manually walk the TokenStream
and find for
followed by await
, transform that to #[await] for
then run ^^.
That can be follow up work though...
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.
Done in c1d4aef
No description provided.