Crates.io | compile_ops |
lib.rs | compile_ops |
version | 0.1.3 |
source | src |
created_at | 2019-12-23 18:44:11.919769 |
updated_at | 2020-01-03 10:41:42.544261 |
description | Compile time operations to not affect your performance and constness with ecuations you can encode. |
homepage | |
repository | https://github.com/NonNullableName/compile_ops/ |
max_upload_size | |
id | 191833 |
size | 17,847 |
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.
#![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));