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

Add special handling of Extension and Clone for debug_handler #2294

Open
davidpdrsn opened this issue Oct 29, 2023 · 5 comments · May be fixed by #2731
Open

Add special handling of Extension and Clone for debug_handler #2294

davidpdrsn opened this issue Oct 29, 2023 · 5 comments · May be fixed by #2731
Assignees
Labels
A-axum-macros C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@davidpdrsn
Copy link
Member

To help with cases like #2293

Basically generate T: Clone for Extension<T> arguments.

We already do something similar for argument ordering so should be possible to extend that.

@davidpdrsn davidpdrsn added C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate A-axum-macros labels Oct 29, 2023
@loganbnielsen
Copy link

Macros operate on the syntax tree and therefore don't generally have knowledge as to whether a trait is implemented for a type. I'm not sure if it's possible to make a check for this using similar techniques from debug_handler.rs. AFAIK, we could only identify whether it's Extension and the T but not whether the T implements Clone (without doing something infeasible like registering all types that implement clone haha)

@jplatte
Copy link
Member

jplatte commented Nov 1, 2023

@loganbnielsen If you look at the existing checks in debug_handler.rs, we already have checks like "inner type of Json in return type position implements Serialize". It works by generating a function like fn assert_serialize<T: Serialize>() {} and calling it as assert_serialize::<InnerType>();.

@loganbnielsen
Copy link

I can publish a PR for this today

@jplatte
Copy link
Member

jplatte commented Nov 1, 2023

Go ahead! This issue is help wanted so PRs are welcome :)

I'll also assign the issue to you so it's easy to see that it has somebody working on it.

@loganbnielsen
Copy link

PR request here.

@jplatte jplatte linked a pull request May 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-axum-macros C-feature-request Category: A feature request, i.e: not implemented / a PR. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants