Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emoun/tt-equal
Macro for token tree equality
https://github.com/emoun/tt-equal
Last synced: about 2 months ago
JSON representation
Macro for token tree equality
- Host: GitHub
- URL: https://github.com/emoun/tt-equal
- Owner: Emoun
- License: apache-2.0
- Created: 2019-08-27T23:29:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-28T15:45:51.000Z (over 5 years ago)
- Last Synced: 2024-08-09T11:15:27.559Z (5 months ago)
- Language: Rust
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
tt-equal
=============================[![Build Status](https://api.travis-ci.org/Emoun/tt-equal.svg?branch=master)](https://travis-ci.org/Emoun/tt-equal)
[![Latest Version](https://img.shields.io/crates/v/tt-equal.svg)](https://crates.io/crates/tt-equal)
[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/tt-equal/0.1/tt_equal/)**This library is an entry in the [`tt_call`](https://crates.io/crates/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`](https://docs.rs/tt-call/1.0.6/tt_call/macro.tt_if.html).```rust
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 constantfn 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.