tt-equal

Crates.iott-equal
lib.rstt-equal
version0.1.2
sourcesrc
created_at2019-08-30 20:05:36.321798
updated_at2019-09-28 15:46:59.985229
descriptionThe macro `tt_equal` acts as a predicate for whether two token trees are equal.
homepage
repositoryhttps://github.com/Emoun/tt-equal
max_upload_size
id160997
size27,637
Emad Jacob Maroun (Emoun)

documentation

https://docs.rs/tt-equal

README

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

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 10

cargo fmt