compile_ops

Crates.iocompile_ops
lib.rscompile_ops
version0.1.3
sourcesrc
created_at2019-12-23 18:44:11.919769
updated_at2020-01-03 10:41:42.544261
descriptionCompile time operations to not affect your performance and constness with ecuations you can encode.
homepage
repositoryhttps://github.com/NonNullableName/compile_ops/
max_upload_size
id191833
size17,847
Dang (NonNullableName)

documentation

README

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)); 
Commit count: 0

cargo fmt