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

macro in_struct

用于在函数中定义结构的类似属性的进程宏

2个稳定版本

1.0.1 2024年4月21日

390进程宏

每月29次下载

MIT 协议

5KB
71

当使用actix时,这个宏对我来说非常有用,您不必为每个可能的JSON创建大量结构,您可以使用这个宏并在函数上方简单定义结构。要使用此宏,您可以执行以下操作

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:

当使用actix时,这个宏对我来说非常有用,您不必为每个可能的JSON创建大量结构,您可以使用这个宏并在函数上方简单定义结构。要使用此宏,您可以执行以下操作

use in_struct::define_struct;

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

依赖项

~245–680KB
~16K SLoC