-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add #[derive(FromRef)]
#1430
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 #[derive(FromRef)]
#1430
Conversation
probably wouldn't work at all since the whole state likely needs `Clone`
d5d3dd2
to
37a7f2c
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.
Should we be re-exporting this and the FromRequest[Parts]
macros like we do debug_handler
?
Yes I think so! Will add that later! |
/// [`State`]: https://docs.rs/axum/0.6/axum/extract/struct.State.html | ||
/// [`#[derive(axum_macros::FromRef)]`]: https://docs.rs/axum-macros/latest/axum_macros/derive.FromRef.html |
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.
Could add axum-macros as a dev-dependency so we can use an intra-doc link here.
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.
Weren't there something with docsrs not building dev dependencies, and that is why we have the __private_docs
feature in axum?
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.
Hm yeah, that might be right.
/// #[derive(FromRef)] | ||
/// struct AppState { | ||
/// auth_token: AuthToken, | ||
/// database_pool: DatabasePool, |
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.
Might be nice to have #[from_ref(skip)]
so you can avoid "weird" impls like FromRef<AppState> for String
.
Doesn't have to be in this PR, of course.
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.
Yeah I've gone back and forth on this. We can add that later if someone requests it.
Given how straight forward this is I think it makes sense to support.
TODO