You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attribute macros are defined by a [public] [function] with the `proc_macro_attribute`[attribute] that has a signature of `(TokenStream, TokenStream) -> TokenStream`. The first [`TokenStream`] is the delimited token tree following the attribute's name, not including the outer delimiters. If the attribute is written as a bare attribute name, the attribute [`TokenStream`] is empty. The second [`TokenStream`] is the rest of the [item] including other [attributes] on the [item]. The returned [`TokenStream`] replaces the [item] with an arbitrary number of [items].
231
+
> [!EXAMPLE]
232
+
> The following attribute macro takes the input stream and returns it as is, effectively being the no-op of attributes.
233
+
>
234
+
> <!-- ignore: test doesn't support proc-macro -->
The `proc_macro_attribute` attribute defines the attribute in the [macro namespace] in the root of the crate.
248
+
> [!EXAMPLE]
249
+
> This following example shows the stringified [`TokenStream`s] that the attribute macros see. The output will show in the output of the compiler. The output is shown in the comments after the function prefixed with "out:".
250
+
>
251
+
> <!-- ignore: test doesn't support proc-macro -->
This following example shows the stringified [`TokenStream`s] that the attribute macros see. The output will show in the output of the compiler. The output is shown in the comments after the function prefixed with "out:".
0 commit comments