Skip to content

Commit 24d7318

Browse files
authored
Merge pull request #457 from yangby-cryptape/fix-typo
Fix typo in a procedural-macros example.
2 parents 457b072 + e5898d2 commit 24d7318

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/procedural-macros.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ second is to emit a [`compile_error`] macro invocation.
3838
3939
### The `proc_macro` crate
4040
41-
Procedural macro crates almost always will link to the compiler-provided
41+
Procedural macro crates almost always will link to the compiler-provided
4242
[`proc_macro` crate]. The `proc_macro` crate provides types required for
4343
writing procedural macros and facilities to make it easier.
4444
@@ -114,7 +114,7 @@ as `make_answer!{}`, `make_answer!();` or `make_answer![];`.
114114
### Derive mode macros
115115

116116
*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].
117+
define new [items] given the token stream of a [struct], [enum], or [union].
118118
They also define [derive mode helper attributes].
119119

120120
Custom deriver modes are defined by a [public] [function] with the
@@ -195,7 +195,7 @@ struct Struct {
195195
*Attribute macros* define new [attributes] which can be attached to [items].
196196

197197
Attribute macros are defined by a [public] [function] with the
198-
`proc_macro_attribute` [attribute] that a signature of
198+
`proc_macro_attribute` [attribute] that a signature of
199199
`(TokenStream, TokenStream) -> TokenStream`. The first [`TokenStream`] is the
200200
attribute's metaitems, not including the delimiters. If the attribute is written
201201
without a metaitem, the attribute [`TokenStream`] is empty. The second
@@ -228,9 +228,9 @@ shown in the comments after the function prefixed with "out:".
228228
# use proc_macro::TokenStream;
229229
230230
#[proc_macro_attribute]
231-
pub fn show_streams(attr: TokenStream, input: TokenStream) -> TokenStream {
231+
pub fn show_streams(attr: TokenStream, item: TokenStream) -> TokenStream {
232232
println!("attr: \"{}\"", attr.to_string());
233-
println!("item: \"{}\"', input.to_string());
233+
println!("item: \"{}\"", item.to_string());
234234
item
235235
}
236236
```
@@ -259,7 +259,7 @@ fn invoke3() {}
259259
// out: attr: "multiple words"
260260
// out: item: "fn invoke3() {}"
261261
262-
// Example:
262+
// Example:
263263
#[show_streams { delimiters }]
264264
fn invoke4() {}
265265
// out: "delimiters"
@@ -292,4 +292,4 @@ fn invoke4() {}
292292
[procedural macro tutorial]: ../book/2018-edition/appendix-04-macros.html#procedural-macros-for-custom-derive
293293
[public]: visibility-and-privacy.html
294294
[struct]: items/structs.html
295-
[unions]: items/unions.html
295+
[union]: items/unions.html

0 commit comments

Comments
 (0)