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
73
use TokenStream;
use ;
/// Generate code by expanding template expressions with substitutions.
///
/// The `xmacro!` macro allows you to define code templates with substitution points
/// and expand them using sets of values. It supports:
///
/// - Named and unnamed definitions
/// - Nested scopes with `${...}`
/// - Single item expansions with `$(...)`
/// - Vertical table-based expansions with `$[...]`
/// - Each-by-each or row-wise expansion modes
///
/// # Example
/// ```rust
/// # use xmacro::xmacro;
/// struct Container<T>(T);
/// trait Trait {}
/// xmacro! {
/// // Define types to substitute
/// $(T: (i32)(u32)(f64))
///
/// // Generate implementations
/// impl Trait for Container<$T> {}
/// }
/// ```
/// Does per item expansion of xmacro definitions.
///
/// Unlike [`xmacro!`] which processes everything in one scope, `xmacro_items!` treats each
/// item independently, expanding them as if each were in its own separate scope. This is
/// particularly useful when generating multiple independent items at module level.
///
/// # Example
///
/// ```rust
/// use xmacro::xmacro_items;
///
/// trait IsInteger {}
/// trait IsSigned {}
/// trait IsUnsigned {}
/// trait IsFloat {}
///
/// xmacro_items! {
/// // Each item expands independently in its own scope
///
/// // Generates specific trait implementations
/// impl IsInteger for $(i8 u64) {}
/// impl IsFloat for $(f32 f64) {}
/// impl IsSigned for $(i8 i16 i32 i64 f32 f64) {}
/// impl IsUnsigned for $(u8 u16 u32 u64) {}
/// }
///
/// // Expands to:
/// // impl IsInteger for i8 {}
/// // same for i16 i32 i64 u8 u16 u32 u64
/// // impl IsFloat for f32 {}
/// // impl IsFloat for f64 {}
/// //impl IsSigned for i8 {}
/// // ... and so on
/// ```