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

Attributes #59

Merged
merged 2 commits into from Aug 13, 2018
Merged

Attributes #59

merged 2 commits into from Aug 13, 2018

Conversation

dtolnay
Copy link
Contributor

@dtolnay dtolnay commented Aug 10, 2018

Fixes #56.

impl_web! {
    impl JsonResource {
        #[get("/")]
        fn hello_world(&self) -> Result<serde_json::Value, ()> {
            Ok(json!({ "message": "hello world" }))
        }
    }
}

@carllerche
Copy link
Owner

Nice... looking through the PR, the trade off would be that #![recursion_limit = "N"] would be required by users?

@dtolnay
Copy link
Contributor Author

dtolnay commented Aug 10, 2018

Yes -- this approach scans the tokens inside the impl block one at a time looking for tower-web attributes. There are ways to process multiple tokens per level of macro recursion to reduce the recursion depth. I pushed a commit to illustrate.

@carllerche
Copy link
Owner

cc @shepmaster

@shepmaster
Copy link
Collaborator

I always find myself (irrationally) annoyed at having to add #![recursion_limit="128"], but it is nice that when the "real" support is added that attribute can just be removed.

Converting my code to the attributes seemed straight-forward and things seemingly continue to work. Overall, I'm happy with the end result as an end-user.

Copy link
Owner

@carllerche carllerche left a comment

Choose a reason for hiding this comment

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

👍

@carllerche carllerche merged commit 2e1a1ef into carllerche:master Aug 13, 2018
@dtolnay dtolnay deleted the attrs branch August 13, 2018 22:25
kornholi pushed a commit to kornholi/tower-web that referenced this pull request Dec 3, 2019
This adds the ability to support attributes on stable Rust while maintaining support
for good error messages.
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.

None yet

3 participants