Skip to content

Commit 57cff8c

Browse files
ehusstraviscross
authored andcommitted
Unwrap proc_macro_derive
1 parent 0c4439d commit 57cff8c

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

src/procedural-macros.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,18 @@ r[macro.proc.derive]
134134
## Derive macros
135135

136136
r[macro.proc.derive.intro]
137-
*Derive macros* define new inputs for the [`derive` attribute]. These macros
138-
can create new [items] given the token stream of a [struct], [enum], or [union].
139-
They can also define [derive macro helper attributes].
137+
*Derive macros* define new inputs for the [`derive` attribute]. These macros can create new [items] given the token stream of a [struct], [enum], or [union]. They can also define [derive macro helper attributes].
140138

141139
r[macro.proc.derive.def]
142-
Custom derive macros are defined by a [public] [function] with the
143-
`proc_macro_derive` attribute and a signature of `(TokenStream) -> TokenStream`.
140+
Custom derive macros are defined by a [public] [function] with the `proc_macro_derive` attribute and a signature of `(TokenStream) -> TokenStream`.
144141

145142
r[macro.proc.derive.namespace]
146143
The `proc_macro_derive` attribute defines the custom derive in the [macro namespace] in the root of the crate.
147144

148145
r[macro.proc.derive.output]
149-
The input [`TokenStream`] is the token stream of the item that has the `derive`
150-
attribute on it. The output [`TokenStream`] must be a set of items that are
151-
then appended to the [module] or [block] that the item from the input
152-
[`TokenStream`] is in.
146+
The input [`TokenStream`] is the token stream of the item that has the `derive` attribute on it. The output [`TokenStream`] must be a set of items that are then appended to the [module] or [block] that the item from the input [`TokenStream`] is in.
153147

154-
The following is an example of a derive macro. Instead of doing anything
155-
useful with its input, it just appends a function `answer`.
148+
The following is an example of a derive macro. Instead of doing anything useful with its input, it just appends a function `answer`.
156149

157150
<!-- ignore: test doesn't support proc-macro -->
158151
```rust,ignore
@@ -185,18 +178,12 @@ r[macro.proc.derive.attributes]
185178
### Derive macro helper attributes
186179

187180
r[macro.proc.derive.attributes.intro]
188-
Derive macros can add additional [attributes] into the scope of the [item]
189-
they are on. Said attributes are called *derive macro helper attributes*. These
190-
attributes are [inert], and their only purpose is to be fed into the derive
191-
macro that defined them. That said, they can be seen by all macros.
181+
Derive macros can add additional [attributes] into the scope of the [item] they are on. Said attributes are called *derive macro helper attributes*. These attributes are [inert], and their only purpose is to be fed into the derive macro that defined them. That said, they can be seen by all macros.
192182

193183
r[macro.proc.derive.attributes.def]
194-
The way to define helper attributes is to put an `attributes` key in the
195-
`proc_macro_derive` macro with a comma separated list of identifiers that are
196-
the names of the helper attributes.
184+
The way to define helper attributes is to put an `attributes` key in the `proc_macro_derive` macro with a comma separated list of identifiers that are the names of the helper attributes.
197185

198-
For example, the following derive macro defines a helper attribute
199-
`helper`, but ultimately doesn't do anything with it.
186+
For example, the following derive macro defines a helper attribute `helper`, but ultimately doesn't do anything with it.
200187

201188
<!-- ignore: test doesn't support proc-macro -->
202189
```rust,ignore

0 commit comments

Comments
 (0)