#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

1.0.1 Apr 21, 2024

#302 in Procedural macros

Download history 168/week @ 2024-04-19 18/week @ 2024-04-26 1/week @ 2024-05-03

187 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

~0.4–0.8MB
~20K SLoC