count-tts-inner 0.1.1

A simple macro for counting any position tokens.
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented3 out of 3 items with examples
  • Size
  • Source code size: 5.81 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 257.81 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • A4-Tacks/count-tts-inner-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • A4-Tacks

Expands to the number of token trees in the inner like macro arguments

Can be used in places where macro expansion is not possible

Similar count_tts crate

Examples

Use count_tts failed case:

use count_tts::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)));

Use this crate case:

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)));
}