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
Copy file name to clipboardExpand all lines: src/macros-by-example.md
+3-13Lines changed: 3 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -330,9 +330,7 @@ r[macro.decl.scope.macro_use]
330
330
### The `macro_use` attribute
331
331
332
332
r[macro.decl.scope.macro_use.mod-decl]
333
-
The *`macro_use` attribute* has two purposes. First, it can be used to make a
334
-
module's macro scope not end when the module is closed, by applying it to a
335
-
module:
333
+
The *`macro_use` attribute* has two purposes. First, it can be used to make a module's macro scope not end when the module is closed, by applying it to a module:
336
334
337
335
```rust
338
336
#[macro_use]
@@ -346,14 +344,7 @@ m!();
346
344
```
347
345
348
346
r[macro.decl.scope.macro_use.prelude]
349
-
Second, it can be used to import macros from another crate, by attaching it to
350
-
an `extern crate` declaration appearing in the crate's root module. Macros
351
-
imported this way are imported into the [`macro_use` prelude], not textually,
352
-
which means that they can be shadowed by any other name. While macros imported
353
-
by `#[macro_use]` can be used before the import statement, in case of a
354
-
conflict, the last macro imported wins. Optionally, a list of macros to import
355
-
can be specified using the [MetaListIdents] syntax; this is not supported
356
-
when `#[macro_use]` is applied to a module.
347
+
Second, it can be used to import macros from another crate, by attaching it to an `extern crate` declaration appearing in the crate's root module. Macros imported this way are imported into the [`macro_use` prelude], not textually, which means that they can be shadowed by any other name. While macros imported by `#[macro_use]` can be used before the import statement, in case of a conflict, the last macro imported wins. Optionally, a list of macros to import can be specified using the [MetaListIdents] syntax; this is not supported when `#[macro_use]` is applied to a module.
357
348
358
349
<!-- ignore: requires external crates -->
359
350
```rust,ignore
@@ -365,8 +356,7 @@ lazy_static!{}
365
356
```
366
357
367
358
r[macro.decl.scope.macro_use.export]
368
-
Macros to be imported with `macro_use` must be exported with
369
-
[`macro_export`][macro.decl.scope.macro_export].
359
+
Macros to be imported with `macro_use` must be exported with [`macro_export`][macro.decl.scope.macro_export].
0 commit comments