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

Declarative macro_rules! derive macros (currently an unimplemented, pre-feature-gated RFC) #191

Open
Kijewski opened this issue Oct 3, 2024 · 0 comments

Comments

@Kijewski
Copy link
Collaborator

Kijewski commented Oct 3, 2024

With rust-lang/rfcs#3698 it would be possible to remove all integration features like with-axum. Instead it would be possible to implement the code generation as a proper macro that is passed as a call-back argument for our generator (untested pseudo-code):

#[doc(hidden)]
pub use {axum_core, rinja};

#[macro_export]
macro_rules! Template {
    ($($tt:tt)*) => {
        $crate::impl_template! {
            [$($tt)*]
            [$crate::rinja]
            [$crate::impl_integration] // in `rinja` itself this argument would be absent
        }
    }
}

#[doc(hidden)]
#[macro_export]
macro_rules! impl_integration {
    (
        [$ident:ident]
        [$($impl_generics:tt)*]
        [$($ty_generics:tt)*]
    ) => {
        impl $($impl_generics)* $crate::axum_core::response::IntoResponse
        for $ident $($ty_generics)* {
            #[inline]
            fn into_response(self) -> $crate::axum_core::response::Response {
                $crate::into_response(&self)
            }
        }
    }
}

This way --all-features would work fine, and everyone could easily implement their own integration crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant