derive2

Crates.ioderive2
lib.rsderive2
version0.1.0
created_at2025-02-12 12:54:16.331616+00
updated_at2025-02-12 12:54:16.331616+00
descriptionAn attribute macro that executes a function-like macro
homepage
repositoryhttps://github.com/mysteriouslyseeing/derive2/
max_upload_size
id1552971
size13,717
Will Schroeder (mysteriouslyseeing)

documentation

README

derive2

Provides #[derive2(...)], an alternative to #[derive(...)] that allows the use of macro_rules macros.

Usage

derive2 takes all its arguments, and calls them like function macros with the item it is applied to:

#[derive2(macro0, macro1)]
#[derive(Default)]
pub enum Foo {
    #[default]
    Bar,
    #[macro0(something)]
    Baz,
}

expands to

#[derive(Default)]
pub enum Foo {
    #[default]
    Bar,
    Baz,
}

macro0! {
    #[derive(Default)]
    pub enum Foo {
        #[default]
        Bar,
        #[macro0(something)]
        Baz,
    }
}
macro1! {
    #[derive(Default)]
    pub enum Foo {
        #[default]
        Bar,
        #[macro0(something)]
        Baz,
    }
}
Commit count: 4

cargo fmt