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 ;
use ;
/// Expands to the number of token trees in the macro arguments
///
/// # Examples
///
/// ```
/// use count_tts_inner::count_tts;
///
/// assert_eq!(count_tts!(), 0);
/// assert_eq!(count_tts!(a b c), 3);
/// assert_eq!(count_tts!(a (b c)), 2);
/// assert_eq!(count_tts!(a, b, c), 5);
/// ```
/// Expands to the number of token trees in the inner like macro arguments
///
/// Can be used in places where macro expansion is not possible
///
/// # Examples
///
/// ```
/// use count_tts_inner::count_tts_inner;
///
/// macro_rules! foo {
/// ($t:literal) => { $t };
/// }
///
/// count_tts_inner! {
/// assert_eq!(0, foo!(#count_tts()));
/// assert_eq!(3, foo!(#count_tts(a b c)));
/// assert_eq!(2, foo!(#count_tts(a (b c))));
/// assert_eq!(5, foo!(#count_tts(a, b, c)));
/// }
/// ```
///
/// # Fail Cases
///
/// ```compile_fail
/// use count_tts_inner::count_tts;
///
/// macro_rules! foo {
/// ($t:literal) => { $t };
/// }
///
/// // Expected literal, `count_tts` `!` `()` is not a literal
/// assert_eq!(0, foo!(count_tts!()));
/// assert_eq!(3, foo!(count_tts!(a b c)));
/// assert_eq!(2, foo!(count_tts!(a (b c))));
/// assert_eq!(5, foo!(count_tts!(a, b, c)));
/// ```