1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use TokenStream;
use ;
use MacroDefinition;
/// Attribute that make the visibility of the `macro_rules!` macro the same as
/// other items.
///
/// So the usage of `#[macro-v]` is private by default, as is the visibility of
/// other items. For example:
///
/// ```rust
/// // Use before declaration
/// private_macro!();
///
/// #[macro_v]
/// macro_rules! private_macro {
/// () => {};
/// }
///
/// mod inner {
/// // You must use the prefix `super::` or `crate::` to call the macro,
/// // because it is not in the current scope
/// super::private_macro!();
/// crate::private_macro!();
/// }
/// ```
///
/// You can also use `#[macro_v(pub(crate))]` to make the macro visible in the
/// current crate. For example:
///
/// ```rust
/// inner::example_macro!();
///
/// // No `#[macro_use]` needed!
/// mod inner {
/// use macro_v::macro_v;
///
/// #[macro_v(pub(crate))]
/// macro_rules! example_macro {
/// () => {};
/// }
/// }
/// ```
///
/// Defining public macros also no longer requires `#[macro_export]`, but
/// instead uses `#[macro-v(pub)]`. For example:
///
/// ```rust
/// pub mod inner {
/// use macro_v::macro_v;
///
/// #[macro_v(pub)]
/// macro_rules! public_macro {
/// () => {};
/// }
/// }
///
/// crate::inner::public_macro!();
/// ```