Skip to content
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

Parse and emit attributes connected to the request/response defs in ruma_api macro #213

Merged
merged 2 commits into from Aug 13, 2020

Conversation

DevinR528
Copy link
Member

@DevinR528 DevinR528 commented Aug 13, 2020

No description provided.

ruma-api-macros/src/api.rs Outdated Show resolved Hide resolved
let attributes =
if let Ok(attrs) = input.call(Attribute::parse_outer) { attrs } else { vec![] };
Copy link
Member

@jplatte jplatte Aug 13, 2020

Choose a reason for hiding this comment

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

I think this kind of thing is usually done using peek rather than taking an alternative branch if parsing fails. I'm not sure what this code would do on unexpected input (i.e. tokens that are none of [attribute, request_ke]).

Copy link
Member Author

@DevinR528 DevinR528 Aug 13, 2020

Choose a reason for hiding this comment

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

This works let attributes = input.call(Attribute::parse_outer)?;

I was wondering about not advancing the "cursor" and stuff I originally did have peek, but the syn docs say to use .call for attributes but now it will fail when it's supposed to I think.

ruma-api-macros/src/api.rs Outdated Show resolved Hide resolved
@jplatte jplatte merged commit a6c1b8f into ruma:master Aug 13, 2020
3 checks passed
@DevinR528 DevinR528 deleted the req/resp-attrs branch Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants