-1

In https://docs.rs/[package]/..., the RHS lists objects like "Modules, Macros, ...". However, how do you see what annotations it exposes?

As a helpful example—this is not the whole question, just an example—serde_json claims to expose only the json macro. However, I know that there are additional macros you can use to annotate struct fields (like "rename"). I clicked into all of the submodules and I didn't find it.

Herohtar
  • 5,347
  • 4
  • 31
  • 41
Test
  • 962
  • 9
  • 26

1 Answers1

2

What you refer to as "annotations" are in fact called "attributes". They are not their own thing but tied to the derive proc macro. Hence they do not appear in the automatically generated documentation and they have to be either read from the source of the proc macro implementation, or they need to be documented by hand. This section in the Rust Reference explains helper attributes for derive macros: Derive macro helper attributes

As for the example of the serde crate family, the derive macro for the Serialize/Deserialize traits are actually defined by the serde_derive crate and the associated attributes are not JSON-specific. The documentation link for serde_derive on crates.io in fact links to a hand-written documentation which explains the intended usage of the attributes in detail.

Jonas Greitemann
  • 1,011
  • 10
  • 25