44Procedural macros come in one of three flavors:
55
66* [ Function-like macros] - ` custom!(...) `
7- * [ Derive mode macros] - ` #[derive(CustomMode )] `
7+ * [ Derive macros] - ` #[derive(CustomDerive )] `
88* [ Attribute macros] - ` #[CustomAttribute] `
99
1010Procedural macros allow you to run code at compile time that operates over Rust
@@ -111,21 +111,21 @@ with curly braces and no semicolon or a different delimiter followed by a
111111semicolon. For example, ` make_answer ` from the previous example can be invoked
112112as ` make_answer!{} ` , ` make_answer!(); ` or ` make_answer![]; ` .
113113
114- ### Derive mode macros
114+ ### Derive macros
115115
116- * Derive mode macros* define new modes for the ` derive ` [ attribute] . These macros
117- define new [ items] given the token stream of a [ struct] , [ enum] , or [ union] .
118- They also define [ derive mode helper attributes] .
116+ * Derive macros* define new inputs for the ` derive ` [ attribute] . These macros
117+ can create new [ items] given the token stream of a [ struct] , [ enum] , or [ union] .
118+ They can also define [ derive macro helper attributes] .
119119
120- Custom deriver modes are defined by a [ public]   ; [ function] with the
120+ Custom derive macros are defined by a [ public]   ; [ function] with the
121121` proc_macro_derive ` attribute and a signature of ` (TokenStream) -> TokenStream ` .
122122
123123The input [ ` TokenStream ` ] is the token stream of the item that has the ` derive `
124124attribute on it. The output [ ` TokenStream ` ] must be a set of items that are
125125then appended to the [ module] or [ block] that the item from the input
126126[ ` TokenStream ` ] is in.
127127
128- The following is an example of a derive mode macro. Instead of doing anything
128+ The following is an example of a derive macro. Instead of doing anything
129129useful with its input, it just appends a function ` answer ` .
130130
131131``` rust,ignore
@@ -138,7 +138,7 @@ pub fn derive_answer_fn(_item: TokenStream) -> TokenStream {
138138}
139139```
140140
141- And then using said derive mode :
141+ And then using said derive macro :
142142
143143``` rust,ignore
144144extern crate proc_macro_examples;
@@ -152,18 +152,18 @@ fn main() {
152152}
153153```
154154
155- #### Derive mode helper attributes
155+ #### Derive macro helper attributes
156156
157- Derive mode macros can add additional [ attributes] into the scope of the [ item]
158- they are on. Said attributes are called * derive mode helper attributes* . These
157+ Derive macros can add additional [ attributes] into the scope of the [ item]
158+ they are on. Said attributes are called * derive macro helper attributes* . These
159159attributes are [ inert] , and their only purpose is to be fed into the derive
160- mode macro that defined them. That said, they can be seen by all macros.
160+ macro that defined them. That said, they can be seen by all macros.
161161
162162The way to define helper attributes is to put an ` attributes ` key in the
163163` proc_macro_derive ` macro with a comma separated list of identifiers that are
164164the names of the helper attributes.
165165
166- For example, the following derive mode macro defines a helper attribute
166+ For example, the following derive macro defines a helper attribute
167167` helper ` , but ultimately doesn't do anything with it.
168168
169169``` rust,ignore
@@ -177,7 +177,7 @@ pub fn derive_helper_attr(_item: TokenStream) -> TokenStream {
177177}
178178```
179179
180- And then usage on the derive mode on a struct:
180+ And then usage on the derive macro on a struct:
181181
182182``` rust,ignore
183183# #![crate_type="proc-macro"]
@@ -272,15 +272,15 @@ fn invoke4() {}
272272[ `derive` ] : attributes.html#derive
273273[ `proc_macro` crate ] : ../proc_macro/index.html
274274[ Cargo's build scripts ] : ../cargo/reference/build-scripts.html
275- [ Derive mode macros ] : #derive-mode -macros
275+ [ Derive macros ] : #derive-macros
276276[ Attribute macros ] : #attribute-macros
277277[ Function-like macros ] : #function-like-procedural-macros
278278[ attribute ] : attributes.html
279279[ attributes ] : attributes.html
280280[ block ] : expressions/block-expr.html
281281[ custom attributes ] : attributes.html
282282[ crate type ] : linkage.html
283- [ derive mode helper attributes ] : #derive-mode -helper-attributes
283+ [ derive macro helper attributes ] : #derive-macro -helper-attributes
284284[ enum ] : items/enumerations.html
285285[ inert ] : attributes.html#active-and-inert-attributes
286286[ item ] : items.html
0 commit comments