-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add macro to compile time check if a path is valid #3288
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
Conversation
6f912ed
to
80505f1
Compare
f8863e2
to
76485a4
Compare
aparently the trick I used is only valid on rust 1.80> so I blocked that via a rustversion call. |
@SabrinaJewson I have fixed all your concerns. can you re-review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I’m not a maintainer of axum! I can just tell you the generic Rust stuff – maintainers might have more overall comments to make.
fe1953f
to
9bec4ab
Compare
This seems like a decent fit for |
no worries at all on my side. I'll move it to axum extras as soon as I'm back home. |
9bec4ab
to
2182e56
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I took a closer look now. Hope this isn't too annoying to deal with a bunch of rounds of feedback!
One final note, if you could add a changelog entry to axum-extra/CHANGELOG.md
that would be nice.
It's my first time contributing to a rust project, and my first time contributing to axum. so, no, it's not annoying, it's the only way that I can learn. (i'm mostly a c++ dev trying to get away from it).
Yes, I'll do that. |
@jplatte did what you asked. but there's a lot of commits that could just be squashed to one. toughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to do anything about the many commits. I usually squash-merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I'm new to rust, so please be kind. :)
For routes created with axum::Router - without the axum_extras TypedRoute, I missed the possibility of a compile time check if the route is valid. I really do prefer the
axum::Router::new().route().route()...to_owned()
approach since it's easy to seeall
of my routes in one single place.the change seemed simple but it took a few days of effort untill I discovered I could open a
const {}
context and work with it.I do not know how to test this, since the test is
compilation failure
on the wrong case.previous api:
my proposal:
first I tried my best to
not
use a macro since they can't be called likeimpl functions
but we work with what we have.on my (400-ish) route project this saved me a bit of time already.