compile_ops 0.1.3

Compile time operations to not affect your performance and constness with ecuations you can encode.
Documentation

compile_ops

This Rust library provides macros that expand to the result of operations like addition,substraction,division,multiplication or power and a macro for join them all.

All the macros support exclusion of expressions thought '!' before they,useful when you cannot prevent code to expand inside the tokens passed;nowadays only possible thought the MBE expansion bucles.

This crate is no_std.

Examples

#![feature(proc_macro_hygiene)]

use compile_ops::*;

assert_eq!(2, add!(1!5, !5, 1)); // five it is not invited...
assert_eq!(2, sub!(3, 1));
assert_eq!(2, mul!(2, 1));
assert_eq!(2, div!(4, 2));
assert_eq!(2, rem!(11, 3));

assert_eq!(2, ops!(2 % 2 + 2 * 2 ^ 1 / 1 - 2));