chuanyue-service/macro/README.MD
2024-10-02 09:08:31 +08:00

11 lines
612 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 注意事项
1. 过程宏,引入其他第三方模块,需要使用`extern crate`引入,或者直接在代码中使用全路径调用,如`axum::http::Response::new(axum::body::Body::from(body))`
2. 过程宏单独放在一个library中需要使用`#[proc_macro_derive]`注解,或者`#[proc_macro]`注解,或者`#[proc_macro_attribute]`注解等
3. 过程宏工程的cargo.toml中需要添加
```toml
[lib]
name = "derive"
path = "src/lib.rs"
proc-macro = true
```
4. 调用过程宏的模块需要将过程宏依赖的包添加到cargo.toml中如domain工程需要添加axum和hyper依赖