Skip to content

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

Merged
jplatte merged 2 commits into
ruma:masterfrom
DevinR528:req/resp-attrs
Aug 13, 2020
Merged

Parse and emit attributes connected to the request/response defs in ruma_api macro#213
jplatte merged 2 commits into
ruma:masterfrom
DevinR528:req/resp-attrs

Conversation

@DevinR528
Copy link
Copy Markdown
Member

No description provided.

Comment thread ruma-api-macros/src/api.rs Outdated
Comment thread ruma-api-macros/src/api.rs Outdated
Comment on lines +440 to +441
let attributes =
if let Ok(attrs) = input.call(Attribute::parse_outer) { attrs } else { vec![] };
Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

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.

Comment thread ruma-api-macros/src/api.rs Outdated
@jplatte jplatte merged commit a6c1b8f into ruma:master Aug 13, 2020
@DevinR528 DevinR528 deleted the req/resp-attrs branch August 13, 2020 22:07
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.

2 participants