Add #[derive(FromRef)] - #1430
Conversation
probably wouldn't work at all since the whole state likely needs `Clone`
d5d3dd2 to
37a7f2c
Compare
jplatte
left a comment
There was a problem hiding this comment.
Should we be re-exporting this and the FromRequest[Parts] macros like we do debug_handler?
|
Yes I think so! Will add that later! |
| /// This trait can be derived using `#[derive(axum_macros::FromRef)]`. | ||
| /// | ||
| /// [`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.
Could add axum-macros as a dev-dependency so we can use an intra-doc link here.
There was a problem hiding this comment.
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.
Hm yeah, that might be right.
| /// #[derive(FromRef)] | ||
| /// struct AppState { | ||
| /// auth_token: AuthToken, | ||
| /// database_pool: DatabasePool, |
There was a problem hiding this comment.
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.
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