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 #[derive(FromRef)] #1430

Merged
merged 15 commits into from Oct 10, 2022
Merged

Add #[derive(FromRef)] #1430

merged 15 commits into from Oct 10, 2022

Conversation

davidpdrsn
Copy link
Member

@davidpdrsn davidpdrsn commented Sep 28, 2022

Given how straight forward this is I think it makes sense to support.

TODO

  • Docs
  • Tests

@davidpdrsn davidpdrsn marked this pull request as ready for review September 29, 2022 15:21
Copy link
Member

@jplatte jplatte left a 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?

axum-macros/src/from_ref.rs Outdated Show resolved Hide resolved
axum-macros/src/from_ref.rs Outdated Show resolved Hide resolved
axum-macros/src/from_ref.rs Outdated Show resolved Hide resolved
@davidpdrsn
Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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,
Copy link
Member

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.

Copy link
Member Author

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.

@davidpdrsn davidpdrsn enabled auto-merge (squash) October 10, 2022 16:14
@davidpdrsn davidpdrsn merged commit 9c0a89c into main Oct 10, 2022
@davidpdrsn davidpdrsn deleted the derive-from-ref branch October 10, 2022 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants