many_op

Macro do_for

Source
macro_rules! do_for {
    (binary $op:tt, $($i:expr;)*) => { ... };
    (binary $op:tt, $($i:expr => $e:expr;)*) => { ... };
    (unary $op:tt, $($i:expr;)*) => { ... };
    (assign $a_op:tt, $($i:expr;)*) => { ... };
}
Expand description

Do an operation for all following variables

ยงExamples

use many_op::do_for;
let mut testvals = [true, true, true];
do_for! {unary !,
   testvals[0];
   testvals[2];
};
assert_eq!(testvals, [false, true, false]);
use many_op::do_for;
let mut testvals = [true, false, true];
do_for! {binary ^, testvals[0];testvals[2];};
assert_eq!(testvals, [false, false, false]);
use many_op::do_for;
let mut testvals = [1, 2, 3];
do_for! {assign +=, testvals[0]; testvals[2];}
assert_eq!(testvals, [2, 2, 6])
use many_op::do_for;
let mut testvals = [1, 2, 3];
do_for! {binary +, testvals[0] => testvals[1]; testvals[2] => testvals[0];}
assert_eq!(testvals, [3, 2, 6])