Skip to content

Commit

Permalink
Merge pull request rust-lang#457 from yangby-cryptape/fix-typo
Browse files Browse the repository at this point in the history
Fix typo in a procedural-macros example.
  • Loading branch information
Havvy authored Oct 23, 2018
2 parents 457b072 + e5898d2 commit 24d7318
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/procedural-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ second is to emit a [`compile_error`] macro invocation.
### The `proc_macro` crate
Procedural macro crates almost always will link to the compiler-provided
Procedural macro crates almost always will link to the compiler-provided
[`proc_macro` crate]. The `proc_macro` crate provides types required for
writing procedural macros and facilities to make it easier.
Expand Down Expand Up @@ -114,7 +114,7 @@ as `make_answer!{}`, `make_answer!();` or `make_answer![];`.
### Derive mode macros

*Derive mode macros* define new modes for the `derive` [attribute]. These macros
define new [items] given the token stream of a [struct], [enum], or [union].
define new [items] given the token stream of a [struct], [enum], or [union].
They also define [derive mode helper attributes].

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

Attribute macros are defined by a [public] [function] with the
`proc_macro_attribute` [attribute] that a signature of
`proc_macro_attribute` [attribute] that a signature of
`(TokenStream, TokenStream) -> TokenStream`. The first [`TokenStream`] is the
attribute's metaitems, not including the delimiters. If the attribute is written
without a metaitem, the attribute [`TokenStream`] is empty. The second
Expand Down Expand Up @@ -228,9 +228,9 @@ shown in the comments after the function prefixed with "out:".
# use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn show_streams(attr: TokenStream, input: TokenStream) -> TokenStream {
pub fn show_streams(attr: TokenStream, item: TokenStream) -> TokenStream {
println!("attr: \"{}\"", attr.to_string());
println!("item: \"{}\"', input.to_string());
println!("item: \"{}\"", item.to_string());
item
}
```
Expand Down Expand Up @@ -259,7 +259,7 @@ fn invoke3() {}
// out: attr: "multiple words"
// out: item: "fn invoke3() {}"
// Example:
// Example:
#[show_streams { delimiters }]
fn invoke4() {}
// out: "delimiters"
Expand Down Expand Up @@ -292,4 +292,4 @@ fn invoke4() {}
[procedural macro tutorial]: ../book/2018-edition/appendix-04-macros.html#procedural-macros-for-custom-derive
[public]: visibility-and-privacy.html
[struct]: items/structs.html
[unions]: items/unions.html
[union]: items/unions.html

0 comments on commit 24d7318

Please sign in to comment.