#struct #define #macro #proc-macro #function #attribute-like #procedural

macro in_struct

An attribute-like procedural macro for defining structs for use in functions

2 stable releases

new 1.0.1 Apr 21, 2024

#323 in Procedural macros

Download history 124/week @ 2024-04-16

124 downloads per month

MIT license

5KB
71 lines

This macro was very useful to me when using actix, instead of making a bunch of structs for each possible json, you can use this macro and simply define the struct with a macro above the functions. To use this macro you can do the following:

use in_struct::define_struct;

#[define_struct(name = Name, derives = [Debug], fields = {field_1: i32, field_2: String})]
fn func(x: Name) {
     println!("{:?}", x);
}

lib.rs:

This macro was very useful to me when using actix, instead of making a bunch of structs for each possible json, you can use this macro and simply define the struct with a macro above the functions. To use this macro you can do the following:

use in_struct::define_struct;

#[define_struct(name = Name, derives = [Debug], fields = {field_1: i32, field_2: String})]
fn func(x: Name) {
    println!("{:?}", x);
}

Dependencies

~320–770KB
~18K SLoC