Attributes
Rust的Attribute
参考资料: Attribute
1 |
|
- Inner attributes, written with a bang (!) after the hash (#), apply to the item that the attribute is declared within.
- Outer attributes, written without the bang after the hash, apply to the thing that follows the attribute.
Attributes
能够分类为以下几类:
1. Testing Attributes
参考资料: https://doc.rust-lang.org/reference/attributes/testing.html
The
test
attribute marks a function to be executed as a test.
Derive
Derive
作用主要有两点:
- use the MetaListPaths to specify a list of traits to implement
- or paths to derive macro to process
简而言之, derive的作用一个是指定trait(可以认为是Java中接口
的近亲), 另一个作用是指定derive macro
宏.
Attributes
https://www.torch-fan.site/2022/07/20/Attribute/