Crate autogen

Source
Expand description

githubcrates-iodocs-rs

§autogen

Tired of repeating all the generics in every impl block or function?

Autogen is a set of macros that allows you to automatically apply generics to impl blocks and functions.

  • the register macro registers the generics of a struct or enum, including lifetimes and the where clause.
  • the apply macro applies the generics to an impl block or function.
#[autogen::register]
struct Struct<'a, T, R: ?Sized>
where
    T: PartialEq,
{
    x: T,
    y: &'a R,
}

#[autogen::apply]
impl Struct {}

This will expand to:

impl<'a, T, R: ?Sized> Struct<'a, T, R> where T: PartialEq {}

For more examples see the register and apply docs.

Attribute Macros§

apply
This macro is used to apply the generics of a struct or enum that have been registered with the register macro to an impl block or function.
register
This macro is used to register the generics of a struct or enum that can later be applied to an impl block or function with the apply macro.