I have a function foo that takes 3 booleans, and I would want to get the result of this function with every combination of bools.
Here is how I did it:
fn foo(b1: bool, b2: bool, b3: bool) -> bool {
b1 && b2 || !b3
}
fn main() {
for b1 in vec![false, true] {
for b2 in vec![false, true] {
for b3 in vec![false, true] {
println!("{} {} {} -> {}", b1, b2, b3, foo(b1, b2, b3));
}
}
}
}
Is there a more direct/ shorter way to do it than creating a vector and then iterate through it?
Is there a way to do it with macros or with mutable functions, so that the compiler just go through each case without iterating?