tt-equal 0.1.2

The macro `tt_equal` acts as a predicate for whether two token trees are equal.
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 27.48 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 274.32 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Emoun/tt-equal
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Emoun

tt-equal

Build Status Latest Version Rust Documentation

This library is an entry in the tt_call series of modular interoperable tt-muncher building blocks.

Inludes the procedural macro tt_equal that acts as a predicate for whether two token trees are equal. Intended for use with tt_if.

use tt_equal::tt_equal;
use tt_call::tt_if;

macro_rules! same_ident{
    {
        $id1:ident, $id2:ident
    } => {
        tt_if!{
            condition = [{tt_equal}]
            input = [{ $id1 $id2 }]         // The two identifiers are here passed to 'tt_equal'
            true = [{
                const $id1: bool = true;
            }]
            false = [{
                const $id1: bool = false;
            }]
        }
    }
}

same_ident!(AN_IDENT, AN_IDENT);            // Equal identifiers result in a true constant
same_ident!(A_DIFFERENT_IDENT, AN_IDENT);   // Different identifiers result in a false constant

fn main() {
    assert_eq!(AN_IDENT, true);
    assert_eq!(A_DIFFERENT_IDENT, false);
}

License