-
Notifications
You must be signed in to change notification settings - Fork 116
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
OpenAPI attribute appears to break named lifetimes in the route handler. #84
Comments
Hmm, this does not look like an easy thing to fix. Will have to take a deeper look if we want to fix this. But why are you using a If someone can show me a use-case where lifetimes are always needed for the function parameters, please share me and I'll take a look at this. |
Hi @ralpha, All good questions. :) A However, and more importantly, most of the return type Really, though, it's not the Even if my use case is not valid because it seems my performance needs are not valid, having a named lifetime in a Rocket handler is definitely a valid use case, and, it is currently broken. For me, personally, I didn't need this API to use [1] https://api.rocket.rs/master/src/rocket/request/from_param.rs.html#195-203 |
Actually, lol, it literally has a TODO, which is awesome. // TODO: Tell the user they're being inefficient? |
Thanks for the replay. You made your case, I'll take a look into allowing lifetimes. (It might not be this release, because this requires changing the derive macro and is sometimes not so strait forward) I want to note though that you are using Not cloning values might be good for performance. But might make code more difficult to maintain (sometimes). So always keep that in mind too. But use-cases also differ, so deepens on your situation. But enough about performance, lets not get to carried away. 😆 I'll let you know once I have take a look at how this can be fixed. |
Ha, nice, I did not know that: thanks for the tip! Yeah, I agree about the performance. In this case, since it's an oembed response, I don't make any I/O, or DB calls. Again, you're definitely right that I likely don't need this performance win of saving those Thanks for taking a look, but no need to rush on my account. As I said, this is sort of a "hidden" API for me, anyway, so I don't need OpenAPI generation. I figured someone else might run into this at some point, so I'd let you know. Awesome work, and I considered taking a stab at it, but my proc macro knowledge is on the order of 1e-9, so I would likely cause more harm than good. 🤣 |
@twitchax I am now running in the same issue, however I need to lifetime the State in rocket, which I cannot own but only borrow - so I need the lifetimes. Example:
And I cannot set lifetime 'x |
I have a similar situation where I want to return a |
+1, also facing this issue. |
same issue here |
…tes regarding issue GREsau#84. Also added an example to showcase the behaviour
Basically what the title says. 😄
If I change to
#[openapi(skip)]
, it works just fine, so I think there is some problem occurring with how the attribute generates code. The error message isSo, it seems like the attribute may be stripping the named lifetime argument from the method definition.
The text was updated successfully, but these errors were encountered: