Please help with Rust terminologies / descriptions

Hi,

In regard to the following page serde.rs | Date in a custom format:

  • Would I be right to describe this #[derive(Serialize, Deserialize, Debug)] as: Custom #[derive] macros which provides implementations for traits Serialize, Deserialize, Debug, please?

  • And how do we call this #[serde(with = "my_date_format")]? And how do we describe what it in plain English, please? Is it an annotation?

Thank you and best regards,

...behai.

The reference calls this “derive macro helper attribute”. It doesn't do anything by itself, instead it is seen and interpreted by the derive macros (for Serialize and Deserialize).

I wouldn't necessarily call the derive macro for Debug a “custom” derive macro, since it comes with the compiler / standard library. Furthermore, note that the fact that the derive macro called “Serialize” implements the trait called “Serialize” and that the derive macro called “Deserialize” implements the trait called “Deserialize”, etc, is technically just a convention. Derive macros could decide themself what traits, possibly even multiple, to generate implementations for (or even generate non-trait-impl items, though that's relatively uncommon).

But otherwise, the terminology you use sounds good to me :slight_smile:

2 Likes

Hi steffahn,

Thank you kindly for your helps and your times. I appreciate that.

Best regards,

...behai.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.