11 lines
612 B
Markdown
11 lines
612 B
Markdown
### 注意事项
|
||
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依赖 |